Handle type load errors in GetExportedTypes

144 views Asked by At

Is there some way in C# to override type load as it is possible for assembly resolve with the AssemblyResolve handler ?

I come from C++, so whenever a type definition is missing from a library, you can always define it somewhere else with the exact same name / namespace and everything will work fine as long as both types have the same layout.

Here I have an assembly referencing a type expected to be found in another assembly, but the type is no longer there. The first library calls GetExportedTypes on itself to register all its type for serialization, but as it cannot find the given type in the second assembly, it fails and nothing is registered in the serializer. The type is actually not used at all in serialization, it is just exported somewhere else.

Is there a way to "redirect" type load, so that I can create a fake type, or is it something that is not possible in dot net ? Or is there any way to avoid GetExportedTypes to throw an exception when it encounters a type it cannot load ?

0

There are 0 answers