app.config location problem
I have small solution, startup project dll project. In the dll project i have added app.config file, start up project doesn't have any config files. I am trying to use app config from the dll project but I am getting
"Object reference not set to an instance of an object."
I try to call it like
ConfigurationManager.ConnectionStrings["SimulatorDB"].ConnectionString;
Seems to me it is looking for the app.config of the sta开发者_如何学Crtup project . this dll project is shared, because of it the config is sitting there.
Any idea how to solve it ? Thanks.
When you run an executable, only the config file associated with that executable is loaded. DLLs cannot have their own config files.
When you build the solution, it will produce the following in the bin\Debug
folder:
StartupApp.exe
StartupApp.exe.config (if there is one)
YourLibrary.dll
Remember this, as the Visual Studio view of things (source code) can be confusing.
精彩评论