[英]Error that reference is missing when it seems to be added to project
I am poking around ASP.Net MVC 5/ASP.Net Core and am getting errors when trying to build the project.我正在浏览 ASP.Net MVC 5/ASP.Net Core,并在尝试构建项目时遇到错误。
The error is simple enough on its own:错误本身就很简单:
Error CS0234 The type or namespace name 'Xrm' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
错误 CS0234 命名空间“Microsoft”中不存在类型或命名空间名称“Xrm”(您是否缺少程序集引用?)
But...it does.但是……确实如此。 The class name in the C# file is correctly 'coloured' and if I hover over it, Visual Studio understands what it is (class
Entity
in picture below). C# 文件中的类名正确地“着色”,如果我将鼠标悬停在它上面,Visual Studio 会理解它是什么(下图中的类
Entity
)。
My main project is a web app, but this problem is occurring in a sibling 'Class Library (package)' project.我的主要项目是一个网络应用程序,但这个问题发生在同级的“类库(包)”项目中。 The reference was added by nuget.
参考是由 nuget 添加的。
Any ideas what I might have done wrong or where I might look to try to debug?任何想法我可能做错了什么或我可能会尝试调试的地方?
The project.json
looks like this: project.json
看起来像这样:
{
"version": "1.0.0-*",
"description": "My Proj Name",
"authors": [ "Robert" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net451": {
"dependencies": {
"Microsoft.Crm.Sdk.Proxy": "1.0.0-*",
"Microsoft.CrmSdk.CoreAssemblies": "8.1.0"
"Microsoft.Xrm.Client": "1.0.0-*"
}
},
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
}
}
You are referencing NuGet Package that has only "full" framework implementation while you are targeting both net451 and dotnet5.当您同时针对 net451 和 dotnet5 时,您正在引用只有“完整”框架实现的 NuGet 包。 Tooltip for the Entity class (asterisk sign) should give you an idea about the error.
实体类的工具提示(星号)应该让您了解错误。
You have two options你有两个选择
eg例如
#if DNX451
// utilize resource only available with .NET Framework
#endif
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.