visual-studiomicrosoft-fakesshim

GENERATEFAKES fails with CS0234


My project builds for my teammates, but not for me.

Project:

project

Errors:

enter image description here

I deleted reference to mscorlib fake, recreated Fake for System, but got the same error. If I try to add reference to mscorlib, I get message:

A reference to 'C:\Windows\Microsoft.NET\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll' could not be added. This component is already automatically referenced by the build system.

I tried to add <Reference Include="mscorlib" /> to the project file, but this did not resolve the issue.

I use VS 2017. Will appreciate any clue.

Thank you @Abhitej, for the answer. It resolved the issue. In addition to switching to higher version of framework I added tags like <Remove FullName="System.Security.Cryptography.CryptoStream"/> for each failing class to both ShimGeneration and StubGeneration in .fakes file.


Solution

  • In most cases like this one its tied to the version of .Net Framework installed on the box. As long as your test project targets the highest version of the Framework on your box, this should work out. Also when dealing with System* namespace please be sure to only generate fakes for types you need excluding others. That should help Fakes deal with API changes over versions and resolve any build errors you might be seeing because of this.

    -Abhitej.