.NET 4 introduced Code Contracts as a new feature. I'd like to use CC, but provide files that can still run in 3.5 SP1. Is that possible? Can I only use parts of the new functionality? Apparently it is possible to have CC only do static checks without being included in the binary files, is that correct?
I'm aware CC was available for 3.5 as separate module, is this a feasible workaround in case I can't use the 4 version of CC? Is there a difference in the feature set?
So to answer your question you only need both if your application uses features from both or altenatively you have separate web applications that use . NET 3.5 and . NET 4.0.
No, they can exist alongside eachother. Just like with previous versions. In fact, 4.0 uses completely different directories to store its assemblies in.
NET Framework 4.5 and later versions are backward-compatible with apps that were built with earlier versions of the . NET Framework. In other words, apps and components built with previous versions will work without modification on the . NET Framework 4.5 and later versions.
NET Framework 4.6. 2 or later by April 26, 2022 to continue receiving technical support and security updates. . NET Framework 3.5 SP1, beginning with Windows 10 version 1809 and Windows Server 2019, is a standalone product and receives 5 years of mainstream support followed by 5 years of extended support.
I'd like to use CC, but provide files that can still run in 3.5 SP1. Is that possible?
You can't use .NET 4.0 CC but you can use Microsoft.Contracts.dll which is the 3.5 CC assembly.
Apparently it is possible to have CC only do static checks without being included in the binary files, is that correct?
Yes. The premium edition includes the static checker, but you need VS2008 Team System or VS2010 Premium/Ultimate to use Code Contracts Premium Edition.
I'm aware CC was available for 3.5 as separate module, is this a feasible workaround in case I can't use the 4 version of CC?
Yes it is still available. Get it from http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx
Yes, you can use Code Contracts with .NET 3.5 (but you're wise to develop with Visual Studio 2010 so you get tooling support). Just download the MSI from the Code Contracts web site, install and copy the DLLs from C:\Program Files (x86)\Microsoft\Contracts\Contracts\v3.5
to your solution and reference Microsoft.Contracts.dll
explicitly in all projects that make use of it.
If you're bound to an earlier version of Visual Studio than 2010, or a version of 2010 that doesn't have Code Contract support, you can execute ccrewrite.exe
, ccrefgen.exe
and ccdocgen.exe
(located in C:\Program Files (x86)\Microsoft\Contracts\Bin
) from the command line as a post build event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With