This documentation is archived and is not being maintained.

AppDomain.TypeResolve Event

Occurs when the resolution of a type fails.

[Visual Basic]
Public Overridable Event TypeResolve As ResolveEventHandler
public virtual event ResolveEventHandler TypeResolve;
public: virtual __event ResolveEventHandler* TypeResolve;

[JScript] In JScript, you can handle the events defined by a class, but you cannot define your own.

Event Data

The event handler receives an argument of type ResolveEventArgs containing data related to this event. The following ResolveEventArgs property provides information specific to this event.

Property Description
Name Gets the name of the item to resolve.


The TypeResolve event occurs when the common language runtime is unable to determine the assembly that can create the requested type. This can occur if the type is defined in a dynamic assembly, or the type is not defined in a dynamic assembly but the runtime does not know which assembly the type is defined in. The latter situation can occur when Type.GetType is called with a type name that is not qualified with the assembly name.

The ResolveEventHandler for this event can attempt to locate and create the type.

However, the TypeResolve event does not occur if the runtime knows it is not possible to find a type in certain assemblies. For example, this event does not occur if the type is not found in a static assembly because the runtime knows types cannot be added dynamically to static assemblies.

To register an event handler for this event, you must have the permissions described in the Permissions section. If you do not have the appropriate permissions, a SecurityException occurs.

For more information about handling events, see Consuming Events.


[Visual Basic, C#, C++] The following sample demonstrates the TypeResolve event.

[Visual Basic, C#, C++] For this code example to run, you must provide the fully qualified assembly name. For information about how to obtain the fully qualified assembly name, see Assembly Names.

[Visual Basic] 
Imports System
Imports System.Reflection
Imports System.Windows.Forms

Module Test

   Sub Main()
      ' You must supply a valid fully qualified assembly name here. 
      FindType("System.Windows.Forms.TextBox, System.Windows.FormsSystem.Windows.Forms, Version, Culture, PublicKeyToken")
      ' OK!

      ' Failed!

      Dim currentDomain As AppDomain = AppDomain.CurrentDomain
      AddHandler currentDomain.TypeResolve, AddressOf MyResolver
      ' OK!
   End Sub 'Main
   Sub FindType(name As String)
         Dim t As Type = Type.GetType(name, True)
      Catch e As Exception
      End Try
   End Sub 'FindType

   Function MyResolver(sender As Object, args As ResolveEventArgs) As System.Reflection.Assembly
      Console.WriteLine("MyResolver fired...")
      Return GetType(TextBox).Assembly
   End Function 'MyResolver

End Module 'Test

using System;
using System.Reflection;
using System.Windows.Forms;

class Test {
   public static void Main() {
      // You must supply a valid fully qualified assembly name here. 
      FindType("System.Windows.Forms.TextBox, System.Windows.Forms, Version, Culture, PublicKeyToken");
      // OK!

      // Failed!

      AppDomain currentDomain = AppDomain.CurrentDomain;
      currentDomain.TypeResolve += new ResolveEventHandler(MyResolver);
      // OK!

   static void FindType(string name) {
      try {
         Type t = Type.GetType(name, true);
      } catch (Exception e) {
   static Assembly MyResolver(object sender, ResolveEventArgs args) {
      Console.WriteLine("MyResolver fired...");
      return typeof(TextBox).Assembly;

#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::Reflection;
using namespace System::Windows::Forms;

__gc class Test {
   static void FindType(String* name) {
      try {
         Type*  t = Type::GetType(name, true);
      } catch (Exception* e) {

   static Assembly* MyResolver(Object* sender, ResolveEventArgs* args) {
      Console::WriteLine(S"MyResolver fired...");
      return __typeof(TextBox)->Assembly;
   static void test() {
      // You must supply a valid fully qualified assembly name here.
      FindType(S"System.Windows.Forms.TextBox, System.Windows.Forms, Version, Culture, PublicKeyToken");
      // OK!

      // Failed!

      AppDomain*  currentDomain = AppDomain::CurrentDomain;
      currentDomain->TypeResolve += new ResolveEventHandler(0, MyResolver);

      // OK!


int main(){

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

AppDomain Class | AppDomain Members | System Namespace