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 / June 2006

Tip: Looking for answers? Try searching our database.

How to execute code when a DLL loads?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
andrew.miadowicz@gmail.com - 21 Jun 2006 19:25 GMT
I need to run some code when my dll is loaded (specifically when the
Visual Studio designer loads my dll).  I know about static constructors
and I've tried to place the code in there, but the problem is these
don't actually execute until the types they're in get instantiated.
What I actually try to do is to register those types to be used in the
Visual Studio designer for some third party controls.  So I am running
into a chicke and egg problem: I need to register my types so that they
can be used in the designer, but my registration code doesn't run until
somebody uses an instance of one of the types.

It would be nice to have some form of an OnLoad method that would
execute when a DLL first loaded, before any particular types got
instantiated.  Is there such a thing?

I've seen this post:
http://groups.google.com/group/microsoft.public.dotnet.framework/browse_frm/thre
ad/4a31e1c3b11b60aa/dcf5a967885d63a7?q=OnLoad+dll&rnum=1#dcf5a967885d63a7


It seems to suggest such a thing exists, but doesn't explain how to get
a hold of it.

Please help.

Thanks,

Andrew
Mattias Sjögren - 21 Jun 2006 21:20 GMT
Andrew,

>What I actually try to do is to register those types to be used in the
>Visual Studio designer for some third party controls.

Can't you handle such registration in a setup package?

>It seems to suggest such a thing exists, but doesn't explain how to get
>a hold of it.

It does (in .NET 2.0) but not all languages let you define such a
method.

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.

andrew.miadowicz@gmail.com - 23 Jun 2006 07:42 GMT
Mattias,

The "registration" I'm referring to is really just the process of
letting this particular third party control designer know that my
editors are available for it to use.  This registration is not
persisted anywhere outside of the Visual Studio designer memory.  In
fact, if I'm not mistaken (I only had so much time to analyze their
source code) the editors that ship with their package only get
registered when one of their controls (that can host such editors) is
instantiated on the Visual Studio designer.

Besides, in my particular case I'm working on a project in which I both
create and use my custom editors, and consequently no installation
takes place, as everything is a part of one big solution.

As far as the "OnLoad" method I am curious to know if C# 2.0 allows me
to define it somehow.  Are there any other workarounds?

Thanks,

Andrew

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.