Problems in Dapper and MVC VNext

I created a class library for tests of the ASP.NET MVC VNext project.

In this class library, I use Dapper, so I have project.json:

{ "dependencies": { "xunit": "2.1.0-beta2-*", "xunit.runner.dnx": "2.1.0-beta2-*", "Dapper": "1.42.0" }, "commands": { "test": "xunit.runner.dnx" }, "frameworks": { "dnx451": { "dependencies": { "Dapper": "1.42.0" } }, "dnxcore50": { "dependencies": { "System.Collections": "4.0.10-beta-22816", "System.Linq": "4.0.0-beta-22816", "Microsoft.CSharp": "4.0.0-beta-22816", "Dapper": "1.42.0" } } } } 

I keep getting the error:

 The type or namespace name 'Dapper' could not be found (are you missing a using directive or an assembly reference?) MvcProj.Test.DNX Core 5.0 

How can i fix this?

+6
source share
2 answers

Use Dapper Beta

Since dnxcore50 is still in beta, no version of Dapper may require release support. That's why the Dapper guys don't put it in release packages.

DNX Beta Support is available in Dapper Beta . Try using version 1.41.0-beta5 or any other latest version without release in your nuget feed .

 "dependencies": { //... "System.Data.SqlClient": "4.0.0-beta-23225", "Dapper": "1.41.0-beta5" }, 

I am using this in my applications right now and it seems to work well.

+9
source

The problem you see is that Dapper did not build a package for dnxcore50 (CoreCLR). There are 3 ways to resolve this.

  • Remove the "dnxcore50" node from project.json (this means that you will no longer build against dnxcore50 ).
  • In your application code where you use Dapper , surround these code snippets with ifdefs: #if DNX451 .... #endif . This means that you are only using the Dapper application in the dnx451 build dnx451 .
  • Transform Dapper to build dnxcore50 . To do this, you need to get the source code and make the necessary changes to the dnxcore50 .
+5
source

Source: https://habr.com/ru/post/990031/


All Articles