views:

3033

answers:

1

How do I use an app.config file for the .Net part when calling a .Net dll from C++ and the data in the config-file must be read at the .Net runtime startup.

If I use have a foo.dll.config that I call from ConfigurationManager.OpenExeConfiguration("foo.dll") I can access application settings. What I would like to do though is to change some information in <system.data>, namely remove a DbProviderFactory and replace it with a new one.

It seems like this can only be done if the code is put in the exectubales app.config file.

But as I am calling the .Net code from C++, I cannot have an app.config for my executable.

Is there some way to specify a configuration file that is sure to be run right after machine.config when the .Net runtime starts, even though I'm calling the .Net dll through C++?

+3  A: 

You can have myapp.exe.config, and the called .Net assembly will use it, even if myapp.exe is c++ app. I have done this using outlook.exe.config for my outlook addin.

Sunny