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 / July 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anthony LaMark - 31 Jul 2007 03:14 GMT
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!
Mattias Sjögren - 31 Jul 2007 09:53 GMT
>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

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


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.