views:

25

answers:

2

I have a Windows Service which runs a Web Service code in a library. The structure is like this:

MyWindowsService.exe (references to MyServiceLibrary.dll)
MyWindowsService.exe.config
MyServiceLibrary.dll (references to web service)
MyServiceLibrary.dll.config (contains endpoint information about the web service)

The process is like this:

MyWindowsService calls MyServiceLibrary.Method()
MyServiceLibrary.Method() calls WebService.Method()

The problem is I'm getting an error about not able to find any endpoints for MyServiceLibrary unless I add information to MyWindowsService.exe.config too. Is there a way to prevent this? I'd like keep config files seperate from each other if possible.

A: 

The configuration in MyServiceLibrary.dll.config is not getting loaded. Move the web service endpoint configuration into MyService.exe.config.

Dan Mork
I did move the endpoint configuration to MyWindowsService.exe.config and it did work that what I'm trying to avoid. I'd like to keep endpoint configuration in MyServiceLibrary.dll.config only. Any ideas why the config file would not load?
Armagan
This is simply how .NET works. See http://msdn.microsoft.com/en-us/library/ms229689(vs.71).aspx for more information. There is one exception... configuration sections and elements can be moved out to an external file using the "configSource" attribute. See http://weblogs.asp.net/cibrax/archive/2007/07/24/configsource-attribute-on-system-servicemodel-section.aspx for an example and, if you're using WCF, possibly an alternative solution.
Dan Mork
A: 

Do you mean for your Windows Service to call the web service? If that's the case, then the Windows service should not reference the web service assembly (DLL). Instead, you should add a Service Reference to the Windows Service project, pointing to where the web service is hosted. Then, the Windows Service is just another client of the web service.

John Saunders
It's not exactly like this. I've update my question, sorry for the confusion. The process is like this: MyWindowsService calls MyServiceLibrary.Method() and MyServiceLibrary.Method() calls WebService.Method()
Armagan