Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / May 2004

Tip: Looking for answers? Try searching our database.

Strange behavior of Assembly Loader in COM Interop scenario

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Etienne Fortin - 31 May 2004 20:30 GMT
I use a .NET class exposed as a COM object to the unmanaged world. The assy
containing the class is registered for COM with the /codebase option so that
it's not necessary to register the assy in the GAC. This .NET class
dynamically load assy (let's call them plugins) from various location on the
hard drive not necessarily in the executing assy directory structure.

That's it for the setting, now for the strange behavior:

1) The AppBase taken by the Assembly Loader is the base directory of the
unmanaged executable that created my .NET/COM object. This is
understandable. So if I dynamically load an assembly that reference another
assy that is part of my .NET application, it fails since it check for it in
the base directory of the exectuable that initiated construction of the COM
object. I tested that by copying the referenced assy in that unmanaged app
directory and the binding could be made. This behavior is observed when
using Assembly.Load(byte[]) or Assembly.Load(...).

2) When I use Assembly.LoadFrom(), all of a sudden, the AppBase is now the
base directory of MY .NET application! In other word, the directory of the
executing assembly that dynamically load the "plugin" assembly. Isn't it
strange? The .NET documentation states that, in fact, LoadFrom() gives
supplementals probing hints to the assembly loader as to where to search for
the referenced assy. But what is strange is that none of the "hint"
described in the doc apply to the behavior I observe. LoadFrom() should give
an hint that the referenced assy is in the path of the dynamically loaded
assy. It as nothing to do with the base dir of the executing assy. It's like
calling LoadFrom(...) reset the AppBase "property" of the Assembly Loader
and now it correctly points, more or so, to the executing assy.

Anyway, I find this behavior strange. Am I mystaken? Is it a completely
understandable correct and documented behavior?

Etienne Fortin
Andreas H?kansson - 18 Apr 2004 19:49 GMT
Etienne,

   Do you have any good stock tips? Seeing how you are a week and a half
into the future you should. I could really do with a couple of billions so
please
email me some good ones ;)

//Anderas

> I use a .NET class exposed as a COM object to the unmanaged world. The assy
> containing the class is registered for COM with the /codebase option so that
[quoted text clipped - 29 lines]
>
> Etienne Fortin
Andreas H?kansson - 18 Apr 2004 19:52 GMT
Make that six and a half weeks. How did I do on my exam? Do you know? =)

//Andreas

> Etienne,
>
[quoted text clipped - 47 lines]
> >
> > Etienne Fortin

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.