GAC and configfile

  • Thread starter Thread starter Gene Vangampelaere
  • Start date Start date
G

Gene Vangampelaere

Hello,


I have an assembly in the GAC. This dll will be used by different
applications (that is the main advantage of the gac I think)
Now I have this problem : The assemble (dll) uses a assemblyname.config
file. Where do I have to put that file ? into the GAC ? Do I have to do that
with gacutil.exe ? or just drag and drop ?

When I put something (a assembly) in the GAC. Is the file physically there?
or is it just a reference to the path of the file ?
 
Hi Gene,

A Dll cant have its own config file from which values are picked at runtime.
Configuration values are picked from <App>.exe.config (the application that
loads the
DLL) or Web.Config (for a web application) or you can also store settings in
machine.config (not a good practice though).

When you register assemblies in the GAC, they are actually stored in their
respective folders under <WinDir>\assembly and this is transparent to the
user. It is therefore a copy of the assembly file that you registered. If
you make any changes to the assembly, you would need to re-register the
assembly into GAC.
 
For this very reason, I have seen two different approaches to configuration
for the DLL files, which may justifiably need their own settings.

One is that the DLL file's setting should be in the App.Config file. After
all, the app is using the dll. It should be willing to host the DLL's
settings.

The other possibility is that the DLL has an Installer class in it's code.
That installer class can create a registry entry that either contains the
dll's config settings (not my preference), or which simply holds the path to
a seperate config file that the dll will use (this is not too distasteful).

I've seen both in code. They both work. It depends on your app as which
makes sense.

--- Nick

Manoj G said:
Hi Gene,

A Dll cant have its own config file from which values are picked at runtime.
Configuration values are picked from <App>.exe.config (the application that
loads the
DLL) or Web.Config (for a web application) or you can also store settings in
machine.config (not a good practice though).

When you register assemblies in the GAC, they are actually stored in their
respective folders under <WinDir>\assembly and this is transparent to the
user. It is therefore a copy of the assembly file that you registered. If
you make any changes to the assembly, you would need to re-register the
assembly into GAC.

--
HTH,
Manoj G
[MVP , Visual Developer - Visual Basic ]
http://msmvps.com/manoj/

"Gene Vangampelaere"
 
Back
Top