Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / October 2004

Tip: Looking for answers? Try searching our database.

AssemblyResolve/Assembly.LoadFrom/multi-domains

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LF - 19 Oct 2004 02:47 GMT
Hi,

I have a .NET executable which creates multiple AppDomains on demand. The
executable's Main method is marked with LoaderOptimization.MultiDomainHost.
The AppDomains are created on demand. I subscribe to AssemblyResolve for
each AppDomain. I share commonly used assemblies in single directory, much
like GAC. If assembly is not found AssemblyResolve gets fired and I use
Assembly.LoadFrom to load the assembly from shared location and return it.

Please assume that I can't use GAC, due to admin issues.

Is there anything wrong with this? When using MultiDomainHost is there
anything wrong with using Assembly.Load (on same assembly) in one AppDomain
from different path and calling Assembly.LoadFrom from another AppDomain
when responding to AssemblyResolve. The Types created are not used across
AppDomains. They are used solely inside the AppDomains that created them.

I'm thinking that since under MultiDomainHost resources are shared for
strongly named assemblies, there could be problems with different Load
contexts.

Thanks you fro any help on this.
Arne Janning - 19 Oct 2004 04:32 GMT
> I have a .NET executable which creates multiple AppDomains on demand. The
> executable's Main method is marked with
[quoted text clipped - 16 lines]
> strongly named assemblies, there could be problems with different Load
> contexts.

When using LoaderOptimization.MultiDomainHost only assemblies loaded from
the GAC will share machine code (just like LoaderOptimization.MultiDomain
does). Assemblies not loaded from the GAC are assumed to be used only by the
loading AppDomain and use private machine code for each AppDomain that loads
them (just like LoaderOptimization.SingleDomain does). So whether or not the
Assemblies are stronly-named is not important, it is the location of an
assembly in the GAC or not that makes the difference. So the resources of
your assemblies won't get shared anyway.

Cheers

Arne Janning
LF - 19 Oct 2004 12:53 GMT
Oh, ok. What about LoaderOptimization.MultiDomain? Does it also share
resources of GAC assemblies only?

But in any case my original question came up because under certain
conditions I would get ExecutionEngineException from CLR. Doesn't happen if
I don't use AssemblyResolve event and doesn't happen if I use PrivateBinPath
for the same purpose. The exception happens on .NET 1.1, but not on 2.0

>> I have a .NET executable which creates multiple AppDomains on demand. The
>> executable's Main method is marked with
[quoted text clipped - 29 lines]
>
> Arne Janning
Arne Janning - 19 Oct 2004 22:27 GMT
> Oh, ok. What about LoaderOptimization.MultiDomain? Does it also share
> resources of GAC assemblies only?

No.

> But in any case my original question came up because under certain
> conditions I would get ExecutionEngineException from CLR. Doesn't happen
> if I don't use AssemblyResolve event and doesn't happen if I use
> PrivateBinPath for the same purpose. The exception happens on .NET 1.1,
> but not on 2.0

Uff, ExecutionEngineException is a fatal error that should never occur. Such
errors occur mainly when the execution engine has been corrupted or data is
missing. Are you using COM/Interop, P/Invoke?

Cheers

Arne Janning
LF - 20 Oct 2004 01:30 GMT
The component that gets loaded into child AppDomain uses COM/Interop.

Also, have you come accross the following:
I have this component that uses COM/Interop loaded into child AppDomain.
If I try AppDomain.Unload at just the right moment when the code was inside
COM/Interop call, the whole .NET process just goes away( exits, disappears)
without any errors or unhandled exceptions. Unfortunately this happens on
1.1 and 2.0

>> Oh, ok. What about LoaderOptimization.MultiDomain? Does it also share
>> resources of GAC assemblies only?
[quoted text clipped - 16 lines]
>
> Arne Janning
Justin Rogers - 23 Oct 2004 03:51 GMT
> Also, have you come accross the following:
> I have this component that uses COM/Interop loaded into child AppDomain.
> If I try AppDomain.Unload at just the right moment when the code was inside
> COM/Interop call, the whole .NET process just goes away( exits, disappears)
> without any errors or unhandled exceptions. Unfortunately this happens on 1.1
> and 2.0

That is called Fail-Fast... It should definitely happen in 1.1... It should get
fixed in
V2.0.  If you have a case of FailFast in 2.0 please submit it via LadyBug so
that
MS is aware of the code-path and fix it as part of the reliability push.

Killing an AppDomain during a COM/Interop call is pretty nasty. Normally the CLR
should first coalesce all threads at a breakable point before stopping, but it
seems like
they are actually aborting threads and possibly corrupting memory in your
scenario.

Signature

Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.