安装Visual Studio 2015后假冒停止工作 [英] Fakes stopped working after installing Visual Studio 2015

查看:57
本文介绍了安装Visual Studio 2015后假冒停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Visual Studio 2015作为试用版,从那时起,使用伪造品的单元测试将不再编译,甚至在VS 2013上也不会编译.单元测试项目的目标是.net 4.5.

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 建议更改目标框架版本.如果我将目标框架更改为4.6,但该错误消失了,但我无法将项目更新为.net 4.6,因为每个开发人员都必须立即更新.

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.

我得到的错误:

主要参考"mscorlib.4.0.0.0.Fakes"无法解决因为它是针对".NETFramework,Version = 4.6"构建的框架.此版本比当前目标版本高框架".NETFramework,Version = 4.5".

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:

类型或名称空间名称'EventDataAttribute'在命名空间"System.Diagnostics.Tracing" *;

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

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'

然后可以将其从mscorlib.fakes或System.fakes文件中删除

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>

现在,它可能会比此更加细微.为了使其正常工作,我需要将Unit Test项目的目标定位为4.6,以便首次生成mscorlib.4.0.0.0.Fakes .dll.然后,我可以将其重新定位为4.5.1.但是,使用配置可能值得您花一些时间,因为我能够解决类似的问题.

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.

这篇关于安装Visual Studio 2015后假冒停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆