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 / New Users / March 2006

Tip: Looking for answers? Try searching our database.

OnLoad Event for a .Net DLL?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David White - 13 Mar 2006 20:51 GMT
Is there some way for code to be triggered for execution when a .Net 2 DLL file
is loaded? I need to perform some initialization work (like loading other
DLLs). Thanks.
Mattias Sjögren - 13 Mar 2006 21:43 GMT
David,

>Is there some way for code to be triggered for execution when a .Net 2 DLL file
>is loaded? I need to perform some initialization work (like loading other
>DLLs). Thanks.

Yes, but whether or not you can take advantage of it depends on which
language you're coding in.

Can't you do your initialization work in a static constructor?

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.

David White - 13 Mar 2006 22:13 GMT
Thanks. I would be coding in C# here. I do think I could manage to initialize
on first use of a contained class. But there may well be a substancial delay
between this DLL being loaded and a class inside it actually getting used. So I
was hoping that (a) I could use that time to do some work and (b) that if there
was some initialization error it could be reported sooner rather than later.

> David,
>
[quoted text clipped - 8 lines]
>
> Mattias
Mattias Sjögren - 13 Mar 2006 23:42 GMT
>Thanks. I would be coding in C# here.

OK, it doesn't support defining a module initializer.

>I do think I could manage to initialize
>on first use of a contained class. But there may well be a substancial delay
>between this DLL being loaded and a class inside it actually getting used.

Where's the DLL being loaded from? Keep in mind that the CLR doesn't
load assemblies until they are needed, so unless the client explicitly
uses something like Assembly.Load it will not be loaded in advance.

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.


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.