tags:

views:

100

answers:

2

Is there a generic way, without creating and managing your own CLR host, to take over locating and loading a type if that type is not found?

The following is just an example. In your rush to be the first answer, don't suggest the new add-in framework or the MEF as a solution to my question.

An example would be a sample with add-ins. Your app reads a file in that lists the types to use for a particular function. The app attempts to instantiate those types. If they aren't already currently loaded in the appdomain, the method fails. I'm looking for an event I can handle or a component I can provide my own implementation for that will allow me to gracefully handle these situations and provide additional logic for loading these assemblies.


As far as I can tell (unless somebody has an example that works) none of the so-far mentioned AppDomain events fire when a type isn't found.


Wait, apparently this is working! Not sure what I did wrong before, but this event fires good and well.

+4  A: 

There are events on the AppDomain that you can use.

You would want TypeResolve event, and possibly the AssemblyResolve event.

Also, you can read more about how the .net runtime resolves assemblies, so it's possible you could define this information in the probing section.

Darren Kopp
A: 

Isn't that possible just by using AppDomain events?

Lou Franco