Question

I am trying to create a dynamic proxy using Spring.NET and C# for a COM interface. I am currently experimenting using code, not config files. I have code similar to the following:

Type comInterfaceType = typeof(ICOMInterface);
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.AddInterface(comInterfaceType);
proxyFactory.GetProxy();

It blows up at the GetProxy() call with the following exception:

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)]

Is this simply not possible? I am still using Spring.NET 1.1, is this possible in the newer versions (which we will finally be moving to soon)?

UPDATE: After experimenting, I got this same error with slightly different parameters (ie. UnmanagedType 44) when proxying the Form class as well.

Was it helpful?

Solution

It seems this was a result of a bug in Spring.NET 1.1 when generating attributes for proxied methods: https://issues.springsource.org/browse/SPRNET-852?page=com.atlassian.streams.streams-jira-plugin%3Aactivity-stream-issue-tab. We have a solution to test migrating to the latest Spring version, and so I tested this there. It worked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top