Prism调用webservice时可以模块化吗?

发布于 2024-09-29 09:46:07 字数 722 浏览 4 评论 0原文

我正在尝试创建一个演示棱镜应用程序。我的应用程序有一个 shell 项目和另一个具有棱镜服务和视图(和视图模型)的模块。 (主要基于 Mike Taulty 的视频,但使用 WPF 而不是 silverlight)。

我设置了棱镜服务来调用我的网络服务。看起来一切设置都正确,但是当我调用此代码时:

 MyServiceReferenceClient myServiceReferenceClient = new MyServiceReferenceClient();

我收到此错误:

在 ServiceModel 客户端配置部分中找不到引用协定“MyServiceReference.IMyService”的默认端点元素。这可能是因为没有找到适用于您的应用程序的配置文件,或者因为在客户端元素中找不到与此协定匹配的端点元素。

我用 google 搜索了该错误,发现我需要将 app.config 的内容放入我的 shell 项目中才能正常工作。

我将该文件复制到我的 Shell 项目中,它运行得很好。

但我不喜欢这个。棱镜的想法是模块化。如果我必须引用模块中调用的所有 Web 服务,那么 shell 必须比它应该了解的更多地了解每个模块的内部工作原理。

有没有一种方法可以在模块中调用 Web 服务,同时仍然具有模块(通过配置文件)的酷炫 Prism 优势,并且区域是 shell 唯一需要了解的内容?

I am playing around creating a demo prism application. The application I have has a shell project and another module that has a prism service and a view (and a view-model). (mostly based off of Mike Taulty's videos, but in WPF rather than silverlight).

I setup the prism-service to call my web service. It seemed all setup right, but when I call this code:

 MyServiceReferenceClient myServiceReferenceClient = new MyServiceReferenceClient();

I got this error:

Could not find default endpoint element that references contract 'MyServiceReference.IMyService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

I googled the error and found that I needed to put the contents of my app.config into my shell project for it to work.

I copied that file over to my Shell project and it worked just fine.

But I don't like this. The idea of prism is to be modular. If I have to have references to all the web services called in the modules then the shell has to know more about the inner workings of each module than it should.

Is there a way to call web services in modules and still have the cool Prism benefits of modules (via config file) and regions being the only thing the shell needs to know about?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叹梦 2024-10-06 09:46:07

这篇文章以与您相同的方式解决您的问题:http://blogs.southworks.net/matiasb/2009/06/20/how-to-consume-wcf- services-from-composite-application-guidance-for-wpf-and-silverlightprism-v2-modules/。此外,正如您所提到的,它建议在模块内以编程方式配置 WCF,以避免让 Shell 了解它不需要了解的模块信息。

This post delas with your issue in the same way that you did: http://blogs.southworks.net/matiasb/2009/06/20/how-to-consume-wcf-services-from-composite-application-guidance-for-wpf-and-silverlightprism-v2-modules/. Additionally, as you mentioned, it suggests to configure WCF programatically within the module to avoid having the Shell know information it does not need to know about modules.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文