0

I'm trying to load Microsoft.Data.SqlClient using Python.net. I have unpacked the dll into at directory like this:

my directory

assembly_path = r"C:\Users\mike\Projects\Python\pythonnet\microsoft.data.sqlclient.2.0.0\lib\netstandard2.0\Microsoft.Data.SqlClient"  
import sys  
sys.path.append(assembly_path)  
import clr  
clr.AddReference("Microsoft.Data.SqlClient")  
from Microsoft.Data.SqlClient import SqlConnection

I'm getting: unresolved import 'Microsoft.Data.SqlClient'Python(unresolved-import) I've practised on a few System assemblies and they work fine, this is all Windows 10. What have I forgotten to do?

大陸北方網友
  • 3,696
  • 3
  • 12
  • 37
MikeAinOz
  • 126
  • 1
  • 10
  • 24
  • I chopped the dll name off the end and put \\ at the end of the path string and I've had a little luck and moved onto Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x64.dll' – MikeAinOz Aug 25 '20 at 09:21
  • Clearly you need to add all the dependencies of `Microsoft.Data.SqlClient` to the search path too. One way to do it is to make an empty dotnet console app, reference the package, then do `dotnet publish --framework net471` – LOST Aug 25 '20 at 18:35
  • Thanks, I'll try that. I have tried putting the sni dll on the path but I wondered if it needed something else – MikeAinOz Aug 25 '20 at 19:37

0 Answers0