I did the following:
- Created a new Web.Api project: "WFW3". I used the "Web API" template under ASP.Net 5.
- I created a new class library, "Foo.Domain", again using ASP.Net 5.
- I added a reference to it from the API project.
- I installed Neo4j.Driver (a portable class library) from Nuget into the Foo.Domain project. Neo4j-NuGet
Everything seemed fine to this point. Everything compiled, though it did nothing.
In Foo.Domain I created a class with a method that referenced the GraphDatabase class inside a 'using' statment. This is where it broke.
I received this error message (and others like it):
The type 'IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly '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
My understanding is that binding redirects are not available in ASP.Net 5. Is this correct? How can I solve this issue not referencing the correct version of System.Runtime? Items found in System.Runtime are available to me. It seems to be looking for an older version of the System.Runtime from within the Neo4j.Driver.V1 assembly. I tried the solution found here (Nathan's answer), but then it started complaining that I was trying to import two different types of the Runtime library and I needed to remove one. But which one should I remove, and how?
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"
]
}
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"
]
}
FooRepository code (in 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;
}
}
}