I'm trying to use code contracts with .NET 3.5 in a large desktop application project, which also have a mixed mode C++ DLL dependency, written in old managed C++ syntax.
The real solution consists of at least 20 projects, but lets assume that there is only A, B, C, and D projects, and the mixed mode M project. C depends on A, B and M. A, B and C are all configured to perform runtime checking, and the code rewrite works well. Now I wanted to add some contracts to one of the higher level assemblies to, called D. D depends on all the others, A, B, C and M too. Now the code rewrite fails for D with the following message (I've changed the names):
15> Reading assembly 'C' from 'build\debug\C.dll' resulted in errors.
15> ccrewrite : error : Rewrite aborted due to metadata errors. Check output window
15> Input string was not in a correct format.
15> Malformed signature.
15> Index was outside the bounds of the array.
15> Malformed signature.
15> Could not resolve type reference: [M]Name.Space.Class1.
15> Could not resolve type reference: [M].EnumType.
15> Malformed signature.
15> Malformed signature.
15> Could not resolve type reference: [M]Name.Space.Class1.
15> Could not resolve type reference: [M].EnumType.
15> Malformed signature.
15> Malformed signature.
15> Input string was not in a correct format.
15> Malformed signature.
15> Could not resolve type reference: [M]Name.Space.Class1.
15> Could not resolve type reference: [M].EnumType.
15> Malformed signature.
15> Malformed signature.
15> Index was outside the bounds of the array.
15> Malformed signature.
Because the messages about M, I think the problem is with the mixed mode C++ DLL. But the C assembly in its own can be code-rewritten succesfully, while it also references M.
I also think that the problem doesn't lie directly in the D assembly, because I've tried it with other higher level assemblies in the same solution and they can't be rewritten by the code contracts tool if they reference C.
The version I'm using is 1.2.21023.14
I've also asked this question in the CodeContracts MSDN forum but haven't received any answers yet, so I thought I'd try here. I'm interested in any workaround or idea related to this.