[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.interop

Advice on dynamically loading .Net assembly when cscript.exe is the hosting process

Anthony LaMark

7/31/2007 2:14:00 AM

Hi All,

I have a .Net Assembly that is COM enabled (COM-Interop) and so is
instantiated and used in vbscript and jscript. I install it into the GAC
(during our installation program). This assembly has dependencies on other
..net assemblies (from another companion product) to run. These dependency
assemblies are not put into the GAC though. When I compile my assembly, I
have the companion product assemblies defined as references within the
Visual Studio project. I can find where the dependency assemblies are on
the hard drive by going to the registry though so I can determine their
location. My current problem is that at run-time I cannot use app.config
file to do load the dependent .net assemblies (because the host process is
cscript.exe which is in Windows\system32), rather I am hoping to be able to
have a hook in my .Net Assembly to be able to load the dependency
assemblies. I have read over Assembly.Load and so it looks do-able but I
think I need to not link the dependencies into the dll (i.e. static link)
since I can see that when the system loads my assembly, it is trying to
resolve the dependency assemblies as well. I see this with fuslogvw.exe.
Any advice would be greatly appreciated!


1 Answer

(Mattias Sjögren)

7/31/2007 8:54:00 AM

0


>I have read over Assembly.Load and so it looks do-able but I
>think I need to not link the dependencies into the dll (i.e. static link)
>since I can see that when the system loads my assembly, it is trying to
>resolve the dependency assemblies as well. I see this with fuslogvw.exe.

The dependencies shouldn't be loaded until they are actually needed.
If you can hook up a handler to the AppDomain.AssemblyResolve event
before using anything from the dependency assemblies you should be
able to handle it from there.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.