Mal*_*ear 6 neo4j portable-class-library asp.net-core asp.net5
我做了以下事情:
到目前为止,一切似乎都很好.一切都编译好了,虽然没有做任何事情.
在Foo.Domain中,我创建了一个类,该方法在"using"语句中引用了GraphDatabase类.这就是它破产的地方.
我收到此错误消息(以及其他类似的消息):
"IDisposable"类型在未引用的程序集中定义.您必须添加对程序集'System.Runtime,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'的引用.Foo.Domain..NET Framework 4.5.1 C:\ dev\WFW3\src\Foo.Domain\FooRepository.cs
我的理解是ASP.Net 5中没有绑定重定向.这是正确的吗?如何解决此问题而不引用正确版本的System.Runtime?在System.Runtime 中找到的项目可供我使用.它似乎是在Neo4j.Driver.V1程序集中寻找旧版本的System.Runtime.我尝试了这里找到的解决方案(Nathan的回答),但后来它开始抱怨我试图导入两种不同类型的Runtime库,我需要删除一个.但是我应该删除哪一个,以及如何删除?
API project.json
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Foo.Domain": "1.0.0-*",
"Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
Run Code Online (Sandbox Code Playgroud)
Foo.Domain project.json
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Foo.Domain": "1.0.0-*",
"Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
Run Code Online (Sandbox Code Playgroud)
FooRepository代码(在Foo.Domain中):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Neo4j.Driver.V1;
namespace Foo.Domain
{
public class FooRepository: IFooRepository
{
public Foo GetById(string Id)
{
// The next lines inside the 'using' are getting the error.
using (var driver = GraphDatabase.Driver("http://localhost:7474/"))
using (var session = driver.Session())
{
var result = session.Run("CREATE (n) RETURN n");
}
return null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
I've found my solution. In addition to removing the 'dnxcore50' framework from the root, web.api library as @Nkosi suggested, I needed to add a 'frameworkAssemblies' section in my class library. The following change to the 'Foo.Domain' library got the solution compiling and behaving as expected.
{
"version": "1.0.0-*",
"description": "Foo.Domain Class Library",
"authors": [ "Malcolm" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net451": {
"frameworkAssemblies": {
"System.Runtime": "4.0.10.0"
}
}
},
"dependencies": {
"Neo4j.Driver": "1.0.0"
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
361 次 |
| 最近记录: |