Assembly loading

K

Kent Rollins

I am writing a server and an MMC console app that use remoting to talk
to each other. The MMC client and the server share a couple of
assemblies: one has the interface that is remoted from the server and
the other has some data structures that are passed across the remoted
interface from the server to the client. These assemblies are not
strong named and are not entered in the GAC. I could easily solve
this problem by putting the DLL in the System32 directory or in the
GAC, but I am trying to understand why it won't load one of the DLLs.

The directories are setup like this:

Machine A
\Program Files\Server\Server.exe
\Program Files\Server\Remote.dll
\Program Files\Server\DataStructs.dll

Machine B
\Program Files\Client\MMCSnapin.dll
\Program Files\Client\Remote.dll
\Program Files\Client\DataStructs.dll

The server runs on Machine A as expected. The MMC console runs on B
with the following problem: it loads the MMCSnapin.dll and Remote.dll
just fine but it can't load DataStructs.dll or atleast it thinks it
can't. I put a breakpoint in the MMCSnapin.dll where it creates the
remoted interface. At that point, I look at the Debug/Modules window
and I see all 3 DLL's loaded. I can even create objects from the
DataStructs.dll with no problem. The problem occurs when I call a
method on the remoted interface that returns one of the objects from
DataStructs.dll. The method throws an exception and says it can't
find the assembly, even though the Modules window says that it is
already loaded. I also checked
AppDomain.CurrentDomain.GetAssemblies() and the DataStructs.dll
assembly is there as it should be.

If I put the DataStructs.dll in the System32 directory where MMC.exe
is, it loads the assembly just fine and calls the remoted method
correctly. I suspect it would behave correctly if I put the assembly
into the GAC as well. But right now, my question is: why does the
Modules window say the assembly is loaded but calling the remoted
method cause it to not be able to find the assembly? I have
repeatedly compiled all components and scoured my drive to make sure
the are no outdated assemblies floating around to confuse things.

Thanks
Kent Rollins
 
S

Sunny

Hi,

your MMC client is acting as part of the MMC proceess, and it's working
directory is System32. You can capture the AppDomain.AssemblyResolve
event, and there to load the assembly you need from where it is.

Sunny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top