By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,726 Members | 2,465 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,726 IT Pros & Developers. It's quick & easy.

How do I move my service reference to its own assembly?

Expert 100+
P: 797
Hi all,

I'm creating a class factory and a bunch of adapters to allow in house applications to communicate with mobile applications over different cellular networks.

I've got my class factory and interface definition [IMobileAdapter] in a single assembly. The class factory will instantiate the correct adapter for communication with a mobile device at runtime. We're doing it this way because we won't know which cellular network we're communicating over until the user specifies the device.

Each adapter will have its own assembly which will contain an implementation of the IMobileAdapter interface specific to the cellular network over which it communicates.

This bit was a piece of cake, I've already created the class factory code and it instantiates the adapters like a charm.

At least one of these adapters uses a service reference (web reference for those still in 2.0 land). When you create the service reference it puts a bunch of stuff in the config file upon which it depends to instantiate the service calls.

So now I get to instantiate an adapter through my class factory in my application [a third assembly].

It is here that I'm running into an issue: It appears that the creation of the service reference is failing because the configuration appears in the app.config for the adapter assembly (which is where it needs to be). When I move the configuration from the adapter assembly into the app.config file in my main application, everything works like a charm.

The issue with this is that the service configuration is not relevant to the main application, and developers using the adapter shouldn't need to know anything about it other than the method calls and return values, including the configuration of said adapter.

Onto my question: Has anyone else had to instantiate service references [or indeed other configuration dependent code] in sub assemblies and how did they [if indeed they did] get their objects to look within its own app.config instead of that of the main application?

I've come across some articles on "per assembly configuration", but it requires writing your own custom code to look at the defined configuration file - this is a simple concept which I could do easily if I was referencing the configuration file from my code. However, because this is a service reference it's more complex in that I haven't found a way to repoint the service reference to a different configuration file.

Jan 23 '09 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.