Can Prism be modular when calling webservices?
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?
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.
精彩评论