类型InvokeMember失败,错误为找不到成员DISP\u E\u MEMBERNOTFOUND,尽管该成员确实存在。
这个
Microsoft Scripting Runtime
VB脚本编写人员熟悉的是Dictionary类,但我无法运行简单的延迟绑定调用。这是MCRE。我还没有开始整理return参数。
static void Main(string[] args)
{
Type type = Type.GetTypeFromProgID("Scripting.Dictionary");
Object com_obj = Activator.CreateInstance(type);
Object[] countArgs = new Object[1];
string msg;
BindingFlags invokeAttr = BindingFlags.InvokeMethod;
try
{
type.InvokeMember("Count", invokeAttr, null, com_obj, null);
}
catch (Exception ex)
{
msg = ex.Message + ":" + ex.InnerException.Message;
Debug.WriteLine(msg);
}
Console.ReadKey();
}