简体   繁体   English

asp.net 5.0 project.json中RavenDB.Client引用的问题

[英]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.

相关问题 Asp.net Core 1.0 project.json预发布脚本 - Asp.net Core 1.0 project.json prepublish scripts 创建新的asp.net核心项目后,Project.json不存在,或者在使用新工具打开解决方案时消失。 - Project.json does not exist after creating a new asp.net core project or disapears when opening a solution with new tooling 最新版本的ReSharper打破了ASP.NET Core 1.0项目中的Bower和project.json'version intellisense' - Latest version of ReSharper breaks both Bower and project.json 'version intellisense' in ASP.NET Core 1.0 projects project.json解决方案项目参考 - project.json solution project reference 无法构建带有project.json的.NET项目 - .NET project with project.json cannot be built 如何在ASP.NET 5 MVC 6的project.json文件中找到要添加的库以及需要指定的版本 - How do I find out what library to add and what version I need to specify in my project.json file for ASP.NET 5 MVC 6 如何在project.json中引用特定版本的NetStandard? - How to reference a specific version of NetStandard in project.json? 浏览器不刷新而不重建Project ASP.NET 5.0 - Browser Not Refreshing Without Rebuilding Project ASP.NET 5.0 DependencyResolver Asp.net 5.0 - DependencyResolver Asp.net 5.0 NET Core中使用project.json构建后创建一个文件夹 - Create a folder after build using project.json in NET Core
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM