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