1

我正在尝试使用 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)。

4

1 回答 1

0

这似乎是 Spring.NET 1.1 在为代理方法生成属性时出现错误的结果:https ://issues.springsource.org/browse/SPRNET-852?page=com.atlassian.streams.streams-jira-plugin %3Aactivity-stream-issue-tab。我们有一个解决方案来测试迁移到最新的 Spring 版本,所以我在那里进行了测试。有效。

于 2010-12-21T00:49:32.847 回答