Unlinking in ASP.Net 5, "IDisposable ... does not link"

I have done 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 link to it from the API project.
  • I installed Neo4j.Driver (portable class library) from Nuget in a Foo.Domain project. Neo4j-NuGet

Everything seemed beautiful up to this point. Everything is compiled, although nothing has been done.

In Foo.Domain, I created a class with a method that referenced the GraphDatabase class inside of "use". Here he broke down.

I received this error message (and the like):

The type "IDisposable" is defined in an assembly that is not a reference. You should add a link 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 redirection binding is not available in ASP.Net 5. Is this correct? How can I solve this problem without referring to the correct version of System.Runtime? Elements found in System.Runtime are available to me. He seems to be looking for an older version of System.Runtime from the Neo4j.Driver.V1 build. I tried the solution found ( Nathan answer ), but then he started complaining that I was trying to import two different types of runtime libraries, and I needed to delete them. But which one should be removed and how?

Project.json API

{ "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" ] } 

Code FooRepository (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; } } } 
+5
source share
2 answers

I have found my solution. In addition to removing the "dnxcore50" framework from the root, in the web.api library suggested by @Nkosi, I need to add the " frameworkAssemblies " section in my class library. The next change to the "Foo.Domain" library got the solution compiled and behaved 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" } } 
+1
source

Link to this similar question: What should I do when ASP.NET 5 (vNext) cannot redirect bindings?

The problem with this question is apparently due to the fact that the dnxcore50 structure was included in the project.

 "frameworks": { "dnx451": { }, "dnxcore50": { } } 

and fixing it solved the problem.

 "frameworks": { "dnx451": { } } 

This worked in their case and should also work for you. I believe that you get this due to the lack of dependencies required by the CLR kernel base (dnxcore50), as indicated here:

Frameworks

This snippet will be created for Desktop (dnx451) or Core CLR (dnxcore50). The Core CLR has many additional dependencies, because the packages that make up BCL need to be called ...

 { "frameworks": { "dnx451": {}, "dnxcore50": { "dependencies": { "System.Collections": "4.0.0.0", "System.Collections.Concurrent": "4.0.0.0", "System.ComponentModel": "4.0.0.0", "System.Linq": "4.0.0.0", "System.Reflection": "4.0.10.0", "System.Runtime": "4.0.20.0", "System.Runtime.InteropServices": "4.0.10.0", "System.Threading": "4.0.0.0", "System.Threading.Tasks": "4.0.0.0" } } } } 

That is why when it was removed from the previous question, the project worked. Most of the other posts that I saw related to this issue also suggested removing dnxcore50

You can also look at this for a better understanding ...

platform dependent dependencies

You can also add dependencies for a specific structure as follows:

 { "frameworks": { "dnxcore50":{ "dependencies":{ "System.Runtime": "4.0.0.0" } }, "dnx451":{} } } 

In the above example, the dependency System.Runtime is only needed for the target dnxcore50, not dnx451. It often happens that you will have additional dependencies on the Core CLR, because there are packages that you should depend on the Core CLR that are part of .NET 4.5.x.

Note

Although it is technically true that you do not need the System.Runtime package on .NET 4.5.1, it also does not matter if you add it as a top level. Each of the System.* Packages will work as the top level. Thus, you do not always have to have this separation. You can add System.Runtime as a top-level dependency, and it will not affect your application when on .NET 4.5.1.

Additional reference material:

Diagnosing dependency issues with ASP.NET 5

How can I diagnose missing dependencies (or other bootloader crashes) in dnx?

+1
source

All Articles