[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

InitializeNewDomain problem in custom AppDomainManager

adhingra

10/3/2008 6:13:00 PM

I have written a custom AppDomainManager and put in in the GAC. Then I am
using the Environment variables to point to the Assembly and the type and
then it runs fine. The requirement here is to override the Fusion store
properties (application base, path, etc) of the DEFAULT DOMAIN of the
application.

This technique is very well documented on different blogs from Microsoft as
well as in the book "Customizing the Microsoft .NET Framework Common Language
Runtime" Book by 'Steven Pratschner'

I am not creating a new Domain but trying to change the ApplicationBase and
PrivateBinPath of the "Default Domain". I am very well aware that the
CreateDomain method is not visible to me for the Default Domain but i have a
second chance in the InitializeNewDomain override.

Basically what I am doing is this, say if my exe is located in the following
path with a dependent library

c:\Somefolder\bin\debug\app.exe
c:\Somefolder\bin\debug\library.dll

I override the InitializeNewDomain fucntion on my custom AppDomainManager
and changed the properties on the AppDomainSetup param is as follows:

AppBase = c:\Somefolder\binPrivateBinPath = c:\Somefolder\bin\debug;c:\Somefolder\bin\shared
PrivateBinPathProbe = "exclude"

That way I should be able to copy the dependent library to the shared folder
and it will work.

Now there are contradictory arguments on whether these properties can be
changed or not after a domain has been created. Some documenation says these
cannot be changed where as the blogs and the book explicitly says they can be
changed cause the domain creation is not completed yet. In fact the book
claims that InitializeNewDomain is the only place we can configure these
properties for the DEFAULT DOMAIN as the CreateDomain function is not called
for the process's default domain.

Once the main function is called reading these properties back from the
AppDomain.CurrentDomain.SetupInformation tells me that the new values are set
but when the code tries to load the dependent library that is now MOVED to
the shared dll it cannot find it.

The fusion log viewer has the following for the bind failure. It clearly
shows that whatever was changed in the InitializeNewDomain on the
appdomainsetup param was not passed on to the fusion loader.

This has become a major problem for the solution that I am trying to write.
Any help in this regard will be very much appreciated.

LOG: DisplayName = MyLibrary, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/DEV/PROJECTS/AppDomainSamples/HelloWorld/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = HelloWorld.exe
Calling assembly : HelloWorld, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Attempting download of new URL
file:///C:/DEV/PROJECTS/AppDomainSamples/HelloWorld/bin/Debug/MyLibrary.DLL.
LOG: Attempting download of new URL
file:///C:/DEV/PROJECTS/AppDomainSamples/HelloWorld/bin/Debug/MyLibrary/MyLibrary.DLL.
LOG: Attempting download of new URL
file:///C:/DEV/PROJECTS/AppDomainSamples/HelloWorld/bin/Debug/MyLibrary.EXE.
LOG: Attempting download of new URL
file:///C:/DEV/PROJECTS/AppDomainSamples/HelloWorld/bin/Debug/MyLibrary/MyLibrary.EXE.
LOG: All probing URLs attempted and failed.