Jonnster
Jonnster

Reputation: 3214

C# .NET Service Reference Settings Missing From Config In Setup File

I have a C# class library which references a WCF service. This creates the service settings in the app.config. When I build the app, the settings are in the appname.dll.config correctly. However, when the setup application creates the setup.exe and I install this on another machine, the config file in there is missing the service reference. All it has is my connection string for the Entity Framework Model.

Why is this happening? I need the service reference settings because the machine the service runs on may change from time to time.

EDIT: It seems no-one understands the problem. My setup app installs the dll to the destination directory as well as the dll.config. I know I would then need to copy that config to the exe app but right now there isn't one. That will be up to the client on that machine to copy it from that destination folder to whatever and wherever is needed. The issue is that the dll.config does NOT include the service settings even though the app.config of the dll does and the dll.config in the release directory of the dll does too. For some reason the setup app which creates a setup.exe and is packaging the dll.config is losing this information. I hope that makes it clearer.

Upvotes: 0

Views: 1454

Answers (2)

Peter Ritchie
Peter Ritchie

Reputation: 35881

When you write code in a dll that requires configuration settings, those settings are added to the app.config for the dll. When you want to use that dll in an exe (or web site) you need to copy the appropriate settings from the dll's config to the exe's config.

Once you do that, the installer should get the exe's config and have the correct config sections.

If you don't have an app.config for the exe, create one. If you have one and the installer ins't installing it, make sure it is installing it. The app domain only looks in one file for the config, that defaults to the exe's app config. The only way you're going to get this to work is to get that information into the exe's app config.

Upvotes: 1

Justin Harvey
Justin Harvey

Reputation: 14672

It sounds to me like the service settings are going into the class library config file. Can you check that they are also going into the app.config file for your main application executable.

Upvotes: 0

Related Questions