Replies: 1 comment 3 replies
-
Ran into this also. Through trial and error, I copied DLLs from a build output in the following order:
Worked! |
Beta Was this translation helpful? Give feedback.
-
Ran into this also. Through trial and error, I copied DLLs from a build output in the following order:
Worked! |
Beta Was this translation helpful? Give feedback.
-
Environment
Details
from pythonnet import load
load("coreclr")
import clr
clr.AddReference(r"Microsoft.Data.SqlClient.dll")
from Microsoft.Data.SqlClient import SqlConnection
try:
conn = SqlConnection("")
except Exception as e:
print(e)
print (System.Environment.StackTrace)
exit()
Output:
Microsoft.Data.SqlClient is not supported on this platform.
at Microsoft.Data.SqlClient.SqlConnection..ctor(String connectionString)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeConstructorWithoutAlloc(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Environment.get_StackTrace()
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
at Python.Runtime.PropertyObject.tp_descr_get(BorrowedReference ds, BorrowedReference ob, BorrowedReference tp) in /tmp/build-via-sdist-h3j67_wc/pythonnet-3.0.3/src/runtime/Types/PropertyObject.cs:line 65
More info:
Various online sources suggest that failure to find "Microsoft.Data.SqlClient.SNI.dll" (native part of the implementation) is the root cause of this failure. However putting this dll in the path or manually loading it seems to make no difference. Either it is manually loaded by SqlClient in a weird way or something else is causing this error.
Another suggested solution is to use a very old version of SqlClient or the System.Data.SqlClient and neither are good options as they are obsolete and unreliable.
Also adding a non-empty connection string doesn't matter because SqlClient do not seem to get to the point where this is processed.
Beta Was this translation helpful? Give feedback.
All reactions