HighTechTalks DotNet Forums  

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

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss LoadFrom() searching wrong dir for unmanaged->COM->CLR->.NET remot in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
=?Utf-8?B?Sm9obiBEdWRkeQ==?=
 
Posts: n/a

Default LoadFrom() searching wrong dir for unmanaged->COM->CLR->.NET remot - 08-08-2007 , 04:46 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.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.