简体   繁体   English

NSubstitute -3.x 'ValueType' 在未引用的程序集中定义。 您必须添加对程序集“netstandard”的引用,

[英]NSubstitute -3.x 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard,

I am struggling to find a reason behind this error in my code:我正在努力在我的代码中找到这个错误背后的原因:

ApplicationServiceTests\\Test.cs(29, 13): error CS0012: The type 'ValueType' is defined in an assembly that is not referenced. ApplicationServiceTests\\Test.cs(29, 13):错误 CS0012:类型“ValueType”是在未引用的程序集中定义的。 You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.您必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”的引用。

The code line is:代码行是:

        repo.GetCoveredCards(Arg.Is(cifCode)).Returns(Task.FromResult(new GetCustomerCCPlusResponse()
        {
            CreditCardPlus = new[] { card1, card2 }
        }));

Tools, framework and Package工具、框架和包

.net framework 4.6.1 Visual Studio 2015 using MSBuild 14. NSubstitute 3.1.0 .net 框架 4.6.1 Visual Studio 2015 使用 MSBuild 14。NSubstitute 3.1.0

It seems like when I use NSubstitute version 1.10.0 and it has worked really well.似乎当我使用 NSubstitute 1.10.0 版时,它运行得非常好。

Now the question is why am I getting this error with the latest version of NSubstitute?现在的问题是,为什么使用最新版本的 NSubstitute 会出现此错误?

I had the same issue after updating Visual studio.更新 Visual Studio 后我遇到了同样的问题。 Delete the bin and obj folders from the UT project folder and rebuild the project.删除UT工程文件夹中的bin和obj文件夹,重建工程。 That fixed it for me.那为我修好了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “System.Object”类型在未引用的程序集中定义。 您必须添加对程序集 .netstandard 的引用 - The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard 为什么我得到:“IThirdParty”类型是在未引用的程序集中定义的。 您必须添加对程序集“ThirdPartyAssembly”的引用吗? - Why am I getting: The type 'IThirdParty' is defined in an assembly that is not referenced. You must add a reference to assembly 'ThirdPartyAssembly'? “组件”类型是在未引用的程序集中定义的。 您必须添加对程序集“System.ComponentModel.Primitives”的引用 - The type 'Component' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ComponentModel.Primitives' “MarshalByRefObject”类型是在未引用的程序集中定义的。 您必须添加对程序集 &#39;mscorlib, Version=4.0.0.0 的引用 - The type 'MarshalByRefObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0 类型“ System.Data.Common.DbTransaction”在未引用的程序集中定义。 您必须添加对程序集的引用 - The type 'System.Data.Common.DbTransaction' is defined in an assembly that is not referenced. You must add a reference to assembly System.IObserver&#39;1 <T0> 在未引用的程序集中定义。 您必须添加对程序集的引用 - System.IObserver'1<T0> is defined in an assembly that is not referenced. You must add a reference to assembly 类型“ DbConnection”在未引用的程序集中定义。 我无法添加参考? - The type 'DbConnection' is defined in an assembly that is not referenced. I cannot add the reference? VSCode“您必须添加对程序集&#39;netstandard&#39;的引用”但编译正常 - VSCode "you must add a reference to assembly 'netstandard'" but compiles fine 在未引用的程序集中定义类型“ x”。 VS 2010 C# - The type “x” is defined in an assembly that is not referenced. VS 2010 C# 类型“ IReportServerCredentials”在未引用的程序集中定义。 - type 'IReportServerCredentials' is defined in an assembly that is not referenced.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM