Re: Loading DLLs App.config from alternate location

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Northorn wrote:

DLLs do not have config files, confile files are for *applications*

My company has the following policy for application directory
structure:

/apps
/bin - executables
/dll - DLLs
/config - config files

The only way I've found to get the DLLs to load from outside the
application directory is by adding the following to the
machine.config file:

and setting the DEVPATH environment variable to point to the path of
the DLLs.

NO! Do not do this. It is deprecated in v2.0. Even in 1.1 it is buggy.

This isn't a desirable option because of the extra configuration
required.
Is there any other way to do this?

Well, the company policy is wrong: tell your boss that. .NET requires
that private assemblies without a strong name are under the application
folder (bin, in your scheme). They can be in a subfolder (eg bin/dll)
which can be set through the config file. Libraries with a strong name
can be located anywhere on the machine (or anywhere on the internet),
but you can only do this for a specific version of the library, and this
makes things messy.

Also, I haven't been able to find a way to load an application config
file from any place other then the directory where the application
was executed. Is there any way to change the default location of the
application config file?

The default location is the application folder, and as John's mentioned,
you can change this by creating a .NET host or creating a new
application domain, but it's not an ideal situation.

The bottom line is this: it is far easier to work the way that .NET
works rather than to fight against it. Read through my Fusion tutorial
for more details on assembly loading.

Richard
--
Fusion Tutorial: http://www.grimes.demon.co.uk/workshops/fusionWS.htm
Security Tutorial:
http://www.grimes.demon.co.uk/workshops/securityWS.htm


.



Relevant Pages

  • Re: Application Configuration File for using CRT locally in VC++ 9
    ... applocal and config files doesn't work when you have two of the ... same DLL in a manifest and using applocal. ... the DLLs installed in WinSxS and having policy redirect files in WinSxS). ... rid of the reference to the 21022.8 version of MFC in all your EM DLLs ...
    (microsoft.public.vc.ide_general)
  • Re: App.Config equivalents for dlls?
    ... config files. ... Does anyone know if dlls can have app.configs or something similar? ... > I ask because one of my assembly classes uses a database, ... > avoid hard-coding a database connection string. ...
    (microsoft.public.dotnet.framework)
  • Re: Cant read app.config
    ... DLLs to not use the config files. ... > (running my application in debug mode. ...
    (microsoft.public.dotnet.general)
  • Re: config files
    ... >Since asp.net and windows apps can uave config files, can dlls have them as ...
    (microsoft.public.dotnet.framework)
  • mixed compilation
    ... Can you compile an application statically with respect to some ... libraries and dynamically with respect to others? ... can one use DLLs to build statically linked ... procedure code out of DLL and plug them into your executables, ...
    (comp.os.linux.development.apps)