System.IO.FileNotFoundException with SqlClient

此生再无相见时 提交于 2019-12-01 17:10:25

I guess you may have figured it out already but hope it would save someone precious time

In order to make everything work you would need to reference System.Data.SqlClient in WebApp .NET Framework 4.6.1 project that is referencing your .NET Standard Library. After that everything should work just fine.

Sounds like .NET Standard Library haven't grabbed with itself dependent library binary. There is nothing like "Copy Local" option in .NET Standard references so I don't see any way to check or set this behavior too

We resolved this by adding System.Data.SqlClient as a reference to our netstandard package, just using the nuget package manager. Once that was done Visual Studio did the rest in the Web solution.

It seems like the dependencies are not all added to the netstandard library when adding a package like Dapper.

What I tried:

I was also having the same error. I created a sample web api(2.0) which uses a .net standard 2.0 class library. In this library I am using Dapper and Dapper.Contrib and using their extension methods tried to query db. But was having the same error. I tried adding System.Data.SqlClient nuget package in the class library but it did not work. I am using VS2019 Community Edition. This has happened to me twice. So writing the exact scenario and solution that worked for me.

What Worked:

It was eventually resolved by removing System.Data.SqlClient nuget package from the class library and re-adding it in WebApi.

Which is strange since class library is able to resolve dapper nuget package but not System.Data.SqlClient, from within itself.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!