[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.interop

LoadFrom() searching wrong dir for unmanaged->COM->CLR->.NET remot

John Duddy

8/8/2007 8:46:00 PM

I am using COM to integrate some .NET components into a legacy app, and am
running into a difficulty with locating assemblies.

I have a C# class that is exposed vi COM interop, and registered as a COM
object. I am creating it via CoCreateInstance (in-process) from an unmanaged
C++ client. Since all by assemblies are in a different location (call it
"B") from my unmanaged exe (which lives in "A"), I created a config file with
the assemblyBinding & probing sections. So far so good - I can create the COM
instance and talk to the object all without putting it in the GAC. (BTW - I
cannot put things in the GAC, so I need a non-GAC solution).

In my C# class, I execute a .NET Remoting server process EXE (call it Y.exe)
in the same directory as my assembly (which is a subdirectory of where the
unmanaged program is). This .NET EXE tries to use Assembly.LoadFrom() to
dynamically load an assembly (call it X.dll) in its same directory and fails.
It uses the unqualified path name. The error message in the exception
indicates that it was looking for X.dll in "A" instead of "B".

My understanding was that being a separate program, Y.exe will search for
assembies in the directory it was loaded from ("B"), rather than the
directory of the process hosting the assembly that executed it ("A").
Instead, it seems to be looking in "A".

So, this is what I have:
A/
unmanaged.exe
unmanaged.exe.config (probing=B)
B/
managed_com.dll
Y.exe
X.dll

Any help is greatly appreciated.

Thanks -

John Duddy
PS - I got it to work by explicitly setting the current working directory of
the Y.exe process when I start it. I want to make sure that is a safe
work-around.