我正在尝试使用 Spring.NET 和 C# 为 COM 接口创建一个动态代理。我目前正在尝试使用代码,而不是配置文件。我有类似于以下的代码:
Type comInterfaceType = typeof(ICOMInterface);
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.AddInterface(comInterfaceType);
proxyFactory.GetProxy();
它在 GetProxy() 调用时爆炸,但有以下例外:
System.InvalidOperationException: The property with name ArraySubType can't be found
in the type System.Runtime.InteropServices.MarshalAsAttribute, but is present as
a named property on the attributeData
[System.Runtime.InteropServices.MarshalAsAttribute(
(System.Runtime.InteropServices.UnmanagedType)28, ArraySubType = 0, SizeParamIndex
= 0, SizeConst = 0, IidParameterIndex = 0, SafeArraySubType = 0)]
这根本不可能吗?我仍在使用 Spring.NET 1.1,这在较新的版本中是否可行(我们最终将很快转向)?
更新:经过试验,我在代理 Form 类时也遇到了同样的错误,但参数略有不同(即 UnmanagedType 44)。