AppDomain.AssemblyResolve Event

Occurs when the resolution of an assembly fails.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public event ResolveEventHandler AssemblyResolve
/** @event */
public final void add_AssemblyResolve (ResolveEventHandler value)

/** @event */
public final void remove_AssemblyResolve (ResolveEventHandler value)

JScript supports the use of events, but not the declaration of new ones.

It is the responsibility of ResolveEventHandler for this event to return the assembly that resolves the type, assembly, or resource.

To register an event handler for this event, you must have the required permissions, or a SecurityException is thrown.

For more information about handling events, see Consuming Events.

The following sample demonstrates the AssemblyResolve event.

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.

public class MyType {
   public MyType() {
      Console.WriteLine("MyType instantiated!");

class Test {
   public static void Main() {
      AppDomain currentDomain = AppDomain.CurrentDomain;

      InstantiateMyType(currentDomain);    // Failed!

      currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);

      InstantiateMyType(currentDomain);    // OK!

   static void InstantiateMyType(AppDomain domain) {
      try {
	 // You must supply a valid fully qualified assembly name here.
         domain.CreateInstance("Assembly text name, Version, Culture, PublicKeyToken", "MyType");
      } catch (Exception e) {
   static Assembly MyResolveEventHandler(object sender, ResolveEventArgs args) {
      return typeof(MyType).Assembly;

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0