none
How to get Type info, Method info when assembly is loaded through new app domain rather than current domain RRS feed

  • Question

  • How to get Type info, Method info when assembly is loaded through new app domain rather than current domain.

    This is my sample code that i m using.

    System.AppDomain NewAppDomain;
    Evidence evidence = AppDomain.CurrentDomain.Evidence;
    NewAppDomain = System.AppDomain.CreateDomain("NewApplicationDomain", evidence);

    Now, suppose my assembly has 'Class1' type and i want to create instance of 'Class1' and from the instance i want to get its member info. So how can i do this?

    • Edited by RK Engineer Thursday, March 7, 2013 5:26 AM more info
    • Moved by Ego Jiang Thursday, March 7, 2013 6:01 AM
    Wednesday, March 6, 2013 1:57 PM

Answers

  • Hi Engineer,

    Welcome to the MSDN Forum.

    Please try the following code:

                //1. create an instance
                object c1 = NewAppDomain.CreateInstanceAndUnwrap("AssemblyFullName", "ClassFullName");
                //2. Get a property value
                PropertyInfo pi = c1.GetType().GetProperty("property1");
                object pValue = pi.GetValue(c1, null);
                Console.WriteLine(pValue);

    I hope this will be helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 7, 2013 7:19 AM
    Moderator