如何解决此反映方法问题? [英] How to fix this reflect method issue?

查看:62
本文介绍了如何解决此反映方法问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ocx控件,有一个方法定义如下

I have a ocx control, there is a method define as following

公共虚拟无效setLabel(short nIndex,字符串参数);

public virtual void setLabel(short nIndex, string param);


我将此ocx插入powerpoint,代码如下


I insert this ocx in powerpoint, code as following


  shp = ActiveWindow.Selection..SlideRange.Shapes.AddOLEObject(252.25f,120.62f,379....) object [] invokeArgs;


  shp = ActiveWindow.Selection..SlideRange.Shapes.AddOLEObject(252.25f, 120.62f, 379.。。。)
   object clt = shp.OLEFormat.Object;
   object[] invokeArgs;

  invokeArgs =新对象[] {(short)1,"Content"};
< clt.GetType().InvokeMember("setLabel",  System.Reflection.BindingFlags.InvokeMethod, null,clt,invokeArgs);
  
当调试到最后一个语句时,就会发生错误        &bsp; nbsp; n  

System.Object InvokeDispMethod(System.String,System.Reflection.BindingFlags,System.Object,System.Object [],Boolean [],Int32,System.String [])消息:未知名称. :0x80020006(DISP_E_UNKNOWNNAME))数据:System.Collections.ListDictionaryInternal

 invokeArgs = new object[] {(short)1, "Content" };
 clt.GetType().InvokeMember("setLabel",  System.Reflection.BindingFlags.InvokeMethod, null, clt, invokeArgs);
  
When debug to the last statment, error occurs                   
                  
System.Object InvokeDispMethod(System.String, System.Reflection.BindingFlags, System.Object, System.Object[], Boolean[], Int32, System.String[]) Message: unknow name。 (Except from HRESULT:0x80020006 (DISP_E_UNKNOWNNAME)) Data:System.Collections.ListDictionaryInternal

如何解决这个问题,谢谢

How to slove this issue, Thanks

 

推荐答案

哦!全反射"风格调用!没看到很长时间!

是否可以在\ Microsoft Visual Studio 8 \ VC \ bin \ dumpbin.exe/EXPORTS< file-name> .dll中看到此"setLabel"功能?? 调用.InvokeMember()尚不清楚,我在两侧都看到'clt'变量(甚至作为函数参数...)

如果您已经在进行反射-也许您可以_list_具有"public"签名的所有功能,并确保"setLabel"功能存在?因此,这不是错误的DLL还是强制转换的对象?
Oho ! Full 'reflection' style invoke ! Didn't see that a long time !

Does this 'setLabel' function can be seen in \Microsoft Visual Studio 8\VC\bin\dumpbin.exe /EXPORTS <file-name>.dll ??  It's not clear on what you calling .InvokeMember() - I see 'clt' variable on both sides (even as function parameter...)

And if you already doing reflection - may be you just can _list_ all the function with 'public' signature and make sure that 'setLabel' function exist ? So it's not a wrong DLL or casted object ?


这篇关于如何解决此反映方法问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆