Fakes stopped working after installing Visual Studio 2015

為{幸葍}努か 提交于 2019-12-04 02:35:21

You can probably remove the problem classes. If your build output has statements like

warning CS0115: 'System.Security.Cryptography.X509Certificates.Fakes.StubX509Certificate2.Dispose(bool)': no suitable method found to override 
warning CS0234: The type or namespace name 'EventDataAttribute' does not exist in the namespace 'System.Diagnostics.Tracing'

Then it can be removed from mscorlib.fakes or System.fakes files

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
  <Assembly Name="mscorlib" Version="4.0.0.0"/>
  <StubGeneration>
    <Remove FullName="System.Diagnostics.Tracing"/>
    <Remove FullName="System.Text.Encoding"/>
    <Remove FullName="System.Security.Cryptography" />
  </StubGeneration>
</Fakes>

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:

<Remove FullName="System.FormattableString" />
<Remove FullName="System.IO" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!