1

I have a visual studio solution with projects containing interfaces and contracts decorated respectively with ContractClass and ContractClassFor.

The solution builds correctly under Visual Studio 2010, but it doesn't build with Visual Studio 2012. Error:

EXEC : error CC1019: Type 'Namespace.Interface' specifies the class 'Namespace.ContractClass' as its contract class

I updated to last version of Code Contract tools (1.4.50813.1), ran "devenv /setup" and restarted the machine.

Any help for this? thanks

fra
  • 3,488
  • 5
  • 38
  • 61
  • can you show your code ? – Cybermaxs Sep 24 '12 at 08:24
  • I'm using simple Contract.Requires(argument != null) and Contract.Assert(value != null), nothing more than that – fra Sep 25 '12 at 05:51
  • Have you tried decompiling the output assembly (using eg. dotPeek) and making sure the `[ContractClassFor]` attribute is actually being emitted? I have also encountered this problem, and I'm finding that the `[ContractClassFor]` attribute is not making it into the compiled .dll - causing ccrewrite.exe to generate the error... I have not yet found a solution for this. – MattDavey Nov 06 '12 at 13:13

2 Answers2

0

Have you tried removing "Perform Static Contract Checking" from the properties window?

Artless
  • 4,522
  • 1
  • 25
  • 40
0

Visual studio allows you to change the CodeContract options through the Visual Studio 'project properties' page.

MSDN have a good article on this with some screenshot to assist you (http://msdn.microsoft.com/en-us/magazine/hh148151.aspx)

There is a checkbox labelled "Perform Static Contract Checking" which is a common cause of these issues.

If this doesn't solve your issue, can I suggest you compare the settings you have in VS2012 with the ones in VS2010 for which it worked.

James Wiseman
  • 29,946
  • 17
  • 95
  • 158
  • I never enabled them. I only select "Standard contract requires", "Perform Runtime Contract Checking 'Full'" and Contract Reference Assembly "DoNotBuild" – fra Sep 26 '12 at 05:28
  • I wasn't saying that you had. I assume the code contract project settings for both VS2010 and VS2012 were identical? – James Wiseman Sep 26 '12 at 09:51
  • yes, I build exactly the same files. With VS2010, no problem, but VS 2012 still gives me those errors. – fra Sep 26 '12 at 11:30
  • I wasn't asking about the files, I was asking you to compare the project settings as shown in the link I posted – James Wiseman Sep 26 '12 at 11:36