I've installed Visual Studio 2015 as a try-out and since then my unit tests that use fakes won't compile anymore, not even on VS 2013. The unit test project targets .net 4.5.
Msdn suggest changing the target framework version. The error is gone if I change the targeted framework to 4.6 but I cannot update my project to .net 4.6 as every developer must update at once.
Error that I get:
The primary reference "mscorlib.4.0.0.0.Fakes" could not be resolved because it was built against the ".NETFramework,Version=4.6 fraemwork. This is a higher version than the currently targeted framework ".NETFramework,Version=4.5".
I've also tried to remove the fakes and recreate them but they do not build, I get errors like this:
The type or namespace name 'EventDataAttribute' does not exist in the namespace 'System.Diagnostics.Tracing'*;
Any fixes for this?
You can probably remove the problem classes. If your build output has statements like
Then it can be removed from mscorlib.fakes or System.fakes files
Now, it may be a bit more nuanced than that. In order to get it to work, I needed to target the Unit Test project to 4.6 to generate the mscorlib.4.0.0.0.Fakes .dll the first time. Then I could retarget it back down to 4.5.1. But, working with the config may be worth a bit of your time as I was able to work around a similar problem.
Here's a Microsoft problem report which is where I got the workaround.
I have to mention that besides the solution posted by doobop, which worked for me, also the following lines were required: