For days i have been banging my head against a brick wall, trying to work out a problem that i am having with WCF Services and Silverlight.
My problem is that i have 5 Silverlight Project modules that i read dynamically into one Master Silverlight Application. Each one of these modules has their own Business Layer and DAL so it makes its own calls to its WCF Services, yet when I load the modules into and try to run a WCF command i get an error message saying that my ServiceReference does not exist, this is because the Service is part of the Modules "ServiceReference.c开发者_Python百科onfig" isntead of the Master projects Service Reference.
Is there are away that i can dynamically get the Master Silverlight project to take in a list of ChannelFactory's and then create the channels and read in all the metadata and get rid of the Service Refences totally? How do you get around having to use the Service References?
All of your help is greatfully appreciated, i think im going insane over this one.
Thanks
Robbie
Yes you can do that. You can copy the generated file "Reference.cs", to do this, you have to:
- Show all files in your project.
- Expand the service reference and look for the Reference.cs.
Now you can copy this and add to your project as a normal class and remove the service reference of your application. For the ChannelFactory, yes you can create through this code:
ChannelFactory<IServiceContract> factory = new ChannelFactory<IServiceContract>(endpoint);
IServiceContract channel = factory.CreateChannel();
精彩评论