[英]Problems with RavenDB.Client reference in asp.net 5.0 project.json
I'm trying to build a RavenApiController with the new ASP.NET 5.0 (aka Asp.Net vNext) stuff and can't seem to get the RavenDB.Client references to work at all. 我正在尝试使用新的ASP.NET 5.0(又名Asp.Net vNext)构建一个RavenApiController,并且似乎无法让RavenDB.Client引用完全正常工作。
The error I get is 我得到的错误是
Error CS0246 The type or namespace name 'Raven' could not be found (are you missing a using directive or an assembly reference?) SharedIO.ASP.NET Core 5.0 RavenApiController.cs 3
错误CS0246找不到类型或命名空间名称'Raven'(您是否缺少using指令或程序集引用?)SharedIO.ASP.NET Core 5.0 RavenApiController.cs 3
My project.json is as follows 我的project.json如下
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"exclude": [
"wwwroot"
],
"packExclude": [
"**.kproj",
"**.user",
"**.vspscc"
],
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta2",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta2",
"Microsoft.AspNet.Mvc": "6.0.0-beta2",
"RavenDB.Client": "3.0.3599",
"SharedIOModel": "1.0.0-*"
},
"frameworks": {
"aspnet50": {},
"aspnetcore50": {}
}
} }
The code for RavenApiController.cs which fails to build on the third line begins as: 无法在第三行构建的RavenApiController.cs的代码开头为:
using System;
using Microsoft.AspNet.Mvc;
using Raven.Client;
using Raven.Client.Document;;
namespace SharedIO.Controllers
{
[RequireHttps]
public abstract class RavenAPIController : Controller
{
public IDocumentStore Store
{
get { return LazyDocStore.Value; }
}
Totally stumped. 完全难倒。
For what it's worth intellisense seems to be able to find the reference just fine and I don't get an error until I actually 'build solution. 为什么它的值intellisense似乎能够找到参考就好,我没有得到错误,直到我真正'构建解决方案。
Also Intellisense shows me that (for example) Raven.Client.Document.IDocumentStore is 'Available' in ASP.NET 5.0 but 'Not Available' in 'ASP.NET Core 5.0'. 此外,Intellisense还向我显示(例如)Raven.Client.Document.IDocumentStore在ASP.NET 5.0中是“可用”,但在“ASP.NET Core 5.0”中是“不可用”。
The problem is that you referencing RavenDB.Client
in the top level dependencies node in project.json
. 问题是您在
project.json
中的顶级依赖项节点中引用RavenDB.Client
。 That means that those dependencies are applicable to both Desktop CLR ( aspnet50
) and CoreCLR ( aspnetcore50
). 这意味着这些依赖项适用于Desktop CLR(
aspnet50
)和CoreCLR( aspnetcore50
)。
When you build an ASPNET 5 project, all configurations are built, not just the "active" one. 构建ASPNET 5项目时,将构建所有配置,而不仅仅是“活动”配置。 Mostly sure
RavenDB.Client
works only with the Desktop CLR so move it under a dependencies node under that configuration. 大多数情况下,
RavenDB.Client
仅适用于Desktop CLR,因此请将其移动到该配置下的依赖项节点下。
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta2",
"Microsoft.AspNet.Diagnostics": "1.0.0-beta2",
"Microsoft.AspNet.Mvc": "6.0.0-beta2",
"SharedIOModel": "1.0.0-*"
},
"frameworks": {
"aspnet50": {
"dependencies" : {
"RavenDB.Client": "3.0.3599",
}
},
"aspnetcore50": {}
}
Then you might have to either use some conditional blocks in your code ( #if ASPNET50
) or remove CoreCLR all together. 然后,您可能必须在代码中使用一些条件块(
#if ASPNET50
)或一起删除CoreCLR。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.