Hi all,

I have been reading up on how the CLR resolves assembly references.
However, I am still a little confused about the following scenario:

A Win32 unmanaged EXE calls a C# .NET DLL registered for use as a COM
object using REGASM /CODEBASE.
The C# .NET DLL also references another C# DLL that is not registered
as a COM object.

The Win32 EXE is in the folder C:\Test
The C# DLLs are in the folder E:\Test

When I run the Win32 EXE, it creates the first C# DLL like a COM
object using CoCreateInstance and makes a method call on it. Within
that method call the C# DLL calls the second C# DLL (I added a
reference to it at design time).
This all works fine, my question is, why does it work?

I have been using Fuslogvw.exe to try to determine what is going on ,
but it also throws up more questions. When I do the above test, I get
the following written to the log (I am also logging successful binds
using registry setting ForceLog) :
(Order is from top to bottom in Assembly Binding Log Viewer, I'm not
sure about the date order as these entries aren't always ordered by
date. Anyway these all have the same datetime)
Win32 EXE - Attempt to load first .NET DLL using filepath. The
operation was successful.
        Bind result: hr = 0x0. The operation completed successfully.
Win32 EXE - Attempt to load mscorlib using assembly name. The
operation was successful.
        Bind result: hr = 0x0. The operation completed successfully.
Win32 EXE - Attempt to load first .NET DLL using assembly name. The
operation failed.
        Bind result: hr = 0x80070002. The system cannot find the file
specified.
Win32 EXE - Attempt to load second .NET DLL using assembly name. The
operation failed.
        Bind result: hr = 0x80070002. The system cannot find the file
specified.
Win32 EXE - Attempt to load first .NET DLL using assembly name. The
operation failed.
        Bind result: hr = 0x80070002. The system cannot find the file
specified.

What is happening here? Where is the attempts to load assemblies using
their name coming from?
Why is there no successful bind to second .NET DLL recorded? It is
successfully called after all.

When I using ProcessExplorer (www.sysinternals.com) to see if the two
DLLs are loaded in the Win32 EXE process, I find that they are.

I also tried debugging into the first .NET DLL and even before the
method call does anything, the second .NET DLL is loaded into the
Win32 EXE process. How does this work? Is is because of the reference
to the second .NET dll in the manifest of the first .NET DLL? I though
.NET DLLs where only loaded when used?
Also, how does the first .NET dll find the second one?, after all the
EXE folder is not the same as the DLL folder.

(Note, everything is working fine, I just want to know why it is
working :) )

If anyone could answer any of my questions I would be very grateful.
Thanks a lot,

Charles Gamble.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to