Unable to invoke method during reflection RRS feed

  • Question

  • I am trying to load the assembly from GAC(third party tool), because i need to load the assembly only if it is particular version , and i am trying to invoke a method in it, but it is throwing TargetInvocationException

    PFC below

    a = Assembly.LoadFrom("C:\\WINDOWS\\assembly\\GAC\\ESRI.ArcGIS.AxReaderControl\\\\ESRI.ArcGIS.AxReaderControl.dll");

    Type myType = a.GetTypes()[0];
    MethodInfo myMethod = myType.GetMethod("CheckDocument");
    object obj = a.CreateInstance(myType.FullName);
    object[] objparam2 = new object[1];

    foreach (ParameterInfo param in myMethod.GetParameters())
    objparam2[0] = "testr";
    object x = (bool)myMethod.Invoke(obj, objparam2);
    catch (TargetInvocationException tie)
    if (tie.InnerException is NotImplementedException)
    //I am getting the inner exception as System.Windows.Forms.AxHost+InvalidActiveXStateException

    kindly help me in resolving th same . thanks

    Thursday, May 31, 2012 7:52 AM


All replies