如何在core 3.1中完整使用COM组件
How to use COM components completely in core 3.1
我在核心 3.1 中使用动态访问 COM 组件,但它不起作用。
尝试使用 A small wrapper around COM interop,几乎没问题,除了索引 属性,例如 var sheet = wb.Sheets[1];
我不得不重写 TryGetIndex 函数。所以我必须得到一个comobject的类型
Reflection-with-IDispatch-based-COM-objects,但在核心 3.1 中不起作用:
System.MissingMethodException:“Method not found: 'System.Type System.Runtime.InteropServices.Marshal.GetTypeForITypeInfo(IntPtr)'.”
和
C:\Windows\Microsoft.NET\assembly\GAC_64\CustomMarshalers\v4.0_4.0.0.0__b03f5f7f11d50a3a\CustomMarshalers.dll
C:\Windows\WinSxS\amd64_custommarshalers_b03f5f7f11d50a3a_10.0.17134.1_none_e788457a14459849\CustomMarshalers.dll
已尝试。
谁能帮帮我?
根据 CyrusNajmabadi 的reply
解决
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
{
result = WrapIfRequired(
_instance.GetType()
.InvokeMember(
"Item",
BindingFlags.GetProperty,
Type.DefaultBinder,
_instance,
indexes
));
return true;
}
成功了!谢谢!
我在核心 3.1 中使用动态访问 COM 组件,但它不起作用。
尝试使用 A small wrapper around COM interop,几乎没问题,除了索引 属性,例如 var sheet = wb.Sheets[1];
我不得不重写 TryGetIndex 函数。所以我必须得到一个comobject的类型
Reflection-with-IDispatch-based-COM-objects,但在核心 3.1 中不起作用:
System.MissingMethodException:“Method not found: 'System.Type System.Runtime.InteropServices.Marshal.GetTypeForITypeInfo(IntPtr)'.”
和
C:\Windows\Microsoft.NET\assembly\GAC_64\CustomMarshalers\v4.0_4.0.0.0__b03f5f7f11d50a3a\CustomMarshalers.dll
C:\Windows\WinSxS\amd64_custommarshalers_b03f5f7f11d50a3a_10.0.17134.1_none_e788457a14459849\CustomMarshalers.dll
已尝试。
谁能帮帮我?
根据 CyrusNajmabadi 的reply
解决public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
{
result = WrapIfRequired(
_instance.GetType()
.InvokeMember(
"Item",
BindingFlags.GetProperty,
Type.DefaultBinder,
_instance,
indexes
));
return true;
}
成功了!谢谢!