[英]How to use COM components completely in core 3.1
I'm using dynamic to access COM components in core 3.1, and it's not work.我正在使用动态访问核心 3.1 中的 COM 组件,但它不起作用。
Try with A small wrapper around COM interop , it's almost ok except index property such as var sheet = wb.Sheets[1];
尝试在 COM interop 周围使用一个小包装器,除了诸如
var sheet = wb.Sheets[1];
索引属性之外几乎var sheet = wb.Sheets[1];
I had to override TryGetIndex function.我不得不重写 TryGetIndex 函数。 So I must get the type of a comobject with Reflection-with-IDispatch-based-COM-objects , but it's not work in core 3.1:
因此,我必须使用Reflection-with-IDispatch-based-COM-objects获取 comobject 的类型,但它在核心 3.1 中不起作用:
System.MissingMethodException:“Method not found: 'System.Type System.Runtime.InteropServices.Marshal.GetTypeForITypeInfo(IntPtr)'.”
And和
C:\\Windows\\Microsoft.NET\\assembly\\GAC_64\\CustomMarshalers\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\CustomMarshalers.dll 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 C:\\Windows\\WinSxS\\amd64_custommarshalers_b03f5f7f11d50a3a_10.0.17134.1_none_e788457a14459849\\CustomMarshalers.dll
has been tried.已经尝试过了。
Can anyone help me?谁能帮我?
Solved based on CyrusNajmabadi's reply根据 CyrusNajmabadi 的回复解决
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;
}
It's worked!Thanks!成功了!谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.