Re: Complex Problem with AppDomains, Assembly Loading Contexts and COM Interop
- From: "David Browne" <davidbaxterbrowne no potted meat@xxxxxxxxxxx>
- Date: Wed, 30 Aug 2006 16:21:55 -0500
<andrew.miadowicz@xxxxxxxxx> wrote in message
news:1156544208.532468.270100@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
My team has been struggling with an issue involving assemblies
dynamically loaded into separate app domains in the context of an .Net
extension running in a third party executable via COM Interop. After
.. . .
1. Nothing that I found online or in Steven's book explains what
exactly the COM Interop layer does when creating the CLR to load a the
first .Net assembly. Specifically, I have no clue how the CLR knows to
look for the assembly in the specific directory that actually contains
it. Naturally, such information would be available from Windows
Registry, but I can't seem to find anything that would instruct the CLR
to load such an assembly. Does the COM Interop layer actually
explicitly load the assembly into the CLR by passing the full path and
effectively executing LoadFrom?
2. If, in fact, a LoadFrom is executed, does the COM Interop attempt to
load the assembly by the usual CLR means of looking under the main
executable's directory FIRST? This would explain why copying the dlls
into the executable's directory actually loads them into the default
loading context.
From your description, it looks like if you can get your COM-visibleassembly to load into the default load context instead of the LoadFrom
context, that would be progress.
You can. Just sign and GAC your COM-visible assemblies.
Here's a fusion log from COM interop against a GAC'ed assembly
Notice the host is c:\windows\system32\wscript.exe, yet it's using the
default load context.
*** Assembly Binder Log Entry (8/30/2006 @ 4:10:17 PM) ***
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
Assembly manager loaded from:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable C:\WINDOWS\System32\WScript.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = NORTHAMERICA\dbrowne
LOG: DisplayName = ComLoadContextTest, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=ba7f46e71788619e
(Fully-specified)
LOG: Appbase = file:///C:/WINDOWS/System32/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = WScript.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Download of application configuration file was attempted from
file:///C:/WINDOWS/System32/WScript.exe.config.
LOG: Configuration file C:\WINDOWS\System32\WScript.exe.config does not
exist.
LOG: No application configuration file found.
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: ComLoadContextTest, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=ba7f46e71788619e
LOG: Found assembly by looking in the GAC.
LOG: Binding succeeds. Returns assembly from
C:\WINDOWS\assembly\GAC_MSIL\ComLoadContextTest\1.0.0.0__ba7f46e71788619e\ComLoadContextTest.dll.
LOG: Assembly is loaded in default load context.
David
.
- References:
- Complex Problem with AppDomains, Assembly Loading Contexts and COM Interop
- From: andrew . miadowicz
- Complex Problem with AppDomains, Assembly Loading Contexts and COM Interop
- Prev by Date: How to wait for multiple STA threads to finish?
- Next by Date: Re: Complex Problem with AppDomains, Assembly Loading Contexts and COM Interop
- Previous by thread: Complex Problem with AppDomains, Assembly Loading Contexts and COM Interop
- Next by thread: Re: Complex Problem with AppDomains, Assembly Loading Contexts and COM Interop
- Index(es):
Relevant Pages
|