A have a large web service solution (written in C# targetting .NET 3.5) which is comprised of 16 individual projects (many class libraries, a few web applications and setup projects). It is developed in visual studio 2010.
I was recently experimenting with Microsoft.CodeContracts, and after evaluating it decided that it was not suitable for my needs. I removed all of the code that referenced it, and removed the assembly references from all of the projects that referenced it.
However my web service has now started to randomly return this error message:
"Could not load file or assembly 'Microsoft.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=736440c9b414ea16' or one of its dependencies. The system cannot find the file specified."
How/Why can it still be trying to load that assembly when I have removed all the code & references to it?
On investigating further, I am still finding that Microsoft.Contracts.dll is showing up in the /bin/ folder of my web application, even though no projects reference it. It is also listed as a "detected dependency" in my setup project - but I am 100% certain NONE OF MY PROJECTS ARE USING IT!
This is driving me absolutely nuts - there is obviously something lurking around thats holding the reference. How can I remove all traces of Microsoft.CodeContracts from my solution?
There are numerous XML elements within CSharp project files that start with CodeContracts.
Remove them if you feel you need to do so.
There will be as many sections as you have configurations {Release, Debug} x {Any CPU, Mixed Platforms} = 4. Do this for each *.csproj file in your solution.
Keep in mind that CodeContracts conditionally generate/weave code, so you app might behave differently.