I created an class library for tests of an ASP.NET MVC VNext project.
In this class library I am using Dapper so I have the 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?
Use a beta version of Dapper
Since dnxcore50
is still in beta, none of the release versions of Dapper can claim release support for it it yet. That's why the Dapper guys aren't putting it in the release packages.
DNX beta support is available in the beta versions of Dapper. Try using version 1.41.0-beta5
, or whatever the latest non-release version is in their nuget feed.
"dependencies": {
//...
"System.Data.SqlClient": "4.0.0-beta-23225",
"Dapper": "1.41.0-beta5"
},
I'm using this in my applications right now and it seems to work well.
The problem you're seeing is due to Dapper
not having built a package for dnxcore50
(CoreCLR). There are 3 ways you can resolve this.
"dnxcore50"
node from your project.json
(this means you will not be building against dnxcore50
anymore).Dapper
surround those pieces of code with ifdefs: #if DNX451
.... #endif
. This then makes you're application only use Dapper
in the dnx451
build configuration.Dapper
to build for dnxcore50
. This would require getting the source code and making necessary changes to work on dnxcore50
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With