Newbie query: assembly.config?

  • Thread starter Thread starter Dick Bridges
  • Start date Start date
D

Dick Bridges

I need a config file to keep connection strings used by the business rules
tier. The web.config would work when the module was used with ASP.NET but
not when included in a Windows Application. Is there a config file (and
associated .NET access methods) that is associated with a given assembly?

TIA
 
Dick,
Within your VS.NET project add an app.config file to the project root, this
file looks just like the web.config (without web specific settings),
something like:

<?xml version="1.0" ?>
<configuration>
<configSections>
<!-- only used if you are create custom sections -->
...
</configSections>
<appSettings>
...
</appSettings>
</configuration>

Because of the ability to set which version of the runtime should be used,
VS.NET 2003 always replaces the myproject.exe.config in the output folder,
the bin folder.

You need to add your config file to your VS.NET project's root folder as
app.config, it needs to be named "app.config" without the quotes. When you
build your project VS.NET (both 2002 & 2003) will copy the app.config file
from the project root to your output folder and name it appropriately
(myproject.exe.config).

Depending on the version of C# you may need to add a text or xml file to
create teh app.config, otherwise you may be able to use "Project - Add New
Item - Application Configuration File" which will add a basic app.config
file to your project.

Hope this helps
Jay
 
Thanks for the response. However I don't think app.config is quite the
solution I'm looking for.

I'm looking for assembly-specific configuration files. Something like
"myAssembly.dll.config"? I don't care if the component(s) represented by
myAssembly.dll is being used as part of a web app or a Windows app or hosted
by IE. I would like to ship a "standard" configuration that "travels" with
the assembly.

There's an old saying in the db world: "If the same data is stored in two
different places, one of them is wrong." Same here. If the same component
assembly .dll is used by two (or three or more) "clients", the system should
provide a common configuration option.

Thanks again for your help.
 
Back
Top