Description





Description

Normally a compilation error is generated if code attempts to access a nonexistent member of a class. MissingMemberException is designed to handle cases where an attempt is made to dynamically access a renamed or deleted member of an assembly that is not referenced by its strong name. The MissingMemberException is thrown when code in a dependent assembly attempts to access a missing member in an assembly that was modified.

[Note: The Base Class Library includes the following derived types: MissingFieldException, MissingMethodException. When appropriate, use these types instead of MissingMemberException.]

Example
using System;

using System.Reflection;



/// <summary>

/// Shows why a MissingMemberException is thrown

/// and how to handle it

/// </summary>



public class MissingMemberExceptionSample

{

    public static void Main()

    {

        try

        {

            Type type = typeof(string); 

            type.InvokeMember("Splitt", BindingFlags.InvokeMethod, null, 

                null, null);

        }

        catch (MissingMemberException e) 

            //traps MissingMemberException, but reports MissingMethodException

            //because the subclass is more specific: 

            //MissingMethodException IS-A MissingMemberException

        {

            Console.WriteLine("Caught MissingMemberException\n"+

                "e.GetType reports exception: {0} - '{1}'",

                e.GetType().Name, e.Message);

        }

        Console.WriteLine();

        Console.WriteLine();

        Console.WriteLine("Press Enter to continue");

        Console.ReadLine();

    }

}


The output is

Caught MissingMemberException

e.GetType reports exception: MissingMethodException - 'Method System.String.Spli

tt not found.'





Press Enter to continue



     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows