Take the 2-minute tour ×

The project has a custom configuration section class with a name MyNamespace.MyConfig. The class is stored in a C# library MyNamespace.MyAssembly.dll.

The project has also a console application. The client wants it to be called the same way as the dll, i.e. MyNamespace.MyAssembly.exe.

App.config file has the following definiton:

 <section name="myConfigSection" type="MyNamespace.MyConfig, MyNamespace.MyAssembly"/>

Now the problem is that the application does not find the MyConfig class, because it is looking in the wrong assembly - in the exe file.

The first idea was to be more specific about the name of the assembly, so the ConfigurationManager knows that it should look in the dll and not in the exe:

 <section name="myConfigSection" type="MyNamespace.MyConfig, MyNamespace.MyAssembly.dll"/>

unfortunately this doesn't help, the application says, it cannot find an assembly with a name MyNamespace.MyAssembly.dll.

The only way to make it work is to rename the application assembly to MyNamespace.MyAssembly.Console, but the client doesn't agree with this.

How can I tell the ConfigurationManager that it should look for my MyNamespace.MyConfig class in the MyNamespace.MyAssembly.dll and not in the MyNamespace.MyAssembly.exe ?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Unfortunately, there's no way to instruct .NET to search for .dll first in this situation. Even with a full name of the assembly like

<section name="myConfigSection" type="MyNamespace.MyConfig, MyNamespace.MyAssembly, Version=, Culture=neutral, PublicKeyToken=...."/>

it will still check the current exe first because they share an identical assembly name. I'll suggest using a different output assembly name for your config project without changing project name.

enter image description here

Then use

<section name="myConfigSection" type="MyNamespace.MyConfig, MyNamespace.MyAssemblyConfig />

in the app.config.

share|improve this answer

Your Answer


