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 / CLR / November 2007

Tip: Looking for answers? Try searching our database.

Is there a way to execute code on Assembly loading?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Simon Egli - 08 Nov 2007 03:18 GMT
Hello,

I have an assembly A that implements additional features for another
assembly B and should link itself automatically into the mechanisms of B
when it is loaded. Is there a way to get code executed in assembly A without
explicitly calling a method in A?

Thanx,

Simon
Alexander Vasilevsky - 08 Nov 2007 15:26 GMT
Please use interfaces.

http://www.alvas.net  - Audio tools for C# and VB.Net developers

> Hello,
>
[quoted text clipped - 6 lines]
>
> Simon
Willy Van den Driessche - 08 Nov 2007 23:39 GMT
reflection allows you to call any code (within the .NET CAS security
limits).

> Hello,
>
[quoted text clipped - 6 lines]
>
> Simon
Ben Voigt [C++ MVP] - 12 Nov 2007 16:31 GMT
> Hello,
>
> I have an assembly A that implements additional features for another
> assembly B and should link itself automatically into the mechanisms of B
> when it is loaded. Is there a way to get code executed in assembly A
> without explicitly calling a method in A?

Yes and no.

No, because assembly A won't be loaded until you call a method in A.  Yes,
because using type initializers (static constructor or .cctor) you can run
code of your choice before any other method is called for the first time.

If you are loading assembly A via reflection (Assembly.Load or
Assembly.LoadFrom) then place a custom attribute on assembly A to designate
an entrypoint that the plugin loader should call.  You'll have to add this
feature to the plugin loader, but it will end up being reusable.

> Thanx,
>
> Simon

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.