Can Prism be modular when calling webservices?

瘦欲@ 提交于 2019-12-11 02:34:32

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/4011722/can-prism-be-modular-when-calling-webservices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!