Re: Is there a way to execute code on Assembly loading?




"Simon Egli" <simon_egli65@xxxxxxxxxxx> wrote in message
news:13fad$47328017$544a4183$30309@xxxxxxxxxxxxxxxxxx
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


.



Relevant Pages

  • Re: [9fans] Do we have a catalog of 9P servers?
    ... Private namespaces, resources as files... ... a big difference between mechanisms and features. ... Poorly designed software creates a new ...
    (comp.os.plan9)
  • Re: Migrating a system incrementally. Was: Re: Static vs. Dynamic typing (big advantage or not)
    ... How many times have you gotten it right the first time. ... The only thing better than incremental rework is reducing the odds of ... One prevents it by implementing features in business value order, ... If you try to remove some detail of complexity and make a mistake, ...
    (comp.object)
  • Re: Migrating a system incrementally. Was: Re: Static vs. Dynamic typing (big advantage or not)
    ... How many times have you gotten it right the first time. ... The only thing better than incremental rework is reducing the odds of ... One prevents it by implementing features in business value order, ... If you try to remove some detail of complexity and make a mistake, ...
    (comp.programming)
  • Re: Top Five OpenNETCF
    ... It's kinda like visiting a large city for the first time. ... Visual Developer - Device Application Development MVP ... wondering what the top five or ten handiest features were from those ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: clear contacts content
    ... a mature product in version 4.5. ... WM5 was the first time you lost the ability to select all ... Imagine what features laptops would be missing if MS decided long ago to ... While I disagree with a lot of choices the developers made in WM5, ...
    (microsoft.public.pocketpc)

Loading