TypeResolve & GetType()

  • Thread starter Thread starter ayende
  • Start date Start date
A

ayende

I've a piece of code which does Type.GetType("full.type, name") on a
type that is located in an assembly that is currently not loaded.
I don't have control over the code that call this and I don't have any
control on the string that get passed.
I wanted to use TypeResolve to handle this, but it doesn't get call for
static assemblies.

Any ideas how I can handle this?
 
This event is not called if the runtime knows that requested type cannot be
retieved from an assembly. Does the type you're requesting exists in the
assembly?
 
If the type exists in the assembly then it seems to me that assembly is not
loaded.

Can you try to load that assembly manually and call Assembly.GetType(...)?

Also you can subscribe to AppDomain.AssemblyResolve to get notified if
something bad is happening with assembly load.
 
I've a piece of code which does Type.GetType("full.type, name") on a
type that is located in an assembly that is currently not loaded.
I don't have control over the code that call this and I don't have any
control on the string that get passed.
I wanted to use TypeResolve to handle this, but it doesn't get call for
static assemblies.

Any ideas how I can handle this?
use AssemblyName class to parse the ClassName, & load the assembly if
needed.
 
I'm already subscribing to AssemblyResolve, but it's not getting
called, and I don't know why.
 
Back
Top