Hi,
I have upgraded to .Net framework 4 and have started seeing a strange
issue that appears to be a problem with Dynamic Proxy. The easiest way
to demonstrate it is using Rhino mocks (though I don't think it is a
problem with Rhino mocks itself).
If I create a unit test and in that test do the following:
- generate a stub for an interface defined in a separate strongly
named assembly
- start a COM+ transaction
- generate a second stub for another interface defined in the same
strongly named assembly
I find that the second call the GenerateStub fails with the following
error:
Unable to cast COM object of type 'System.__ComObject' to interface
type 'Microsoft.Runtime.Hosting.IClrStrongName'
And this happens when trying to create a StrongNameKeyPair from inside
the Castle Dynamic Proxy code.
This issue can be demonstrated by running the one and only test in the
sample solution found here:
http://dl.dropbox.com/u/26218407/DynamicProxyIssue.zip.
This only happens if I use .net 4, if the assembly containing the
interfaces to be mocked is strongly named and if I start a COM+
transaction between the two calls to generatestub. Otherwise, the code
works fine.
This is just one way this issue can come up, I have also seen the same
problem with Dynamic Proxy as used in NHibernate when combining
nhibernate transactions and COM+ transactions.
This is preventing us from upgrading to .net 4 so I'd be really
grateful if anyone has a solution.
Thanks,
Julian.