'Why am I getting System.PlatformNotSupportedException when using SqlClient?

I'm using the current master branch of Python.Net 3.0 from GitHub, on Python 3.10, on Windows 10.

I wrote a test DLL in .NET 5 that uses System.Data.SqlClient to perform a single call to a SQL Server instance as a proof-of-concept. I configured the runtimeconfig.json file to correctly identify the .NET version (see https://github.com/pythonnet/pythonnet/issues/984#issuecomment-778786164). But when executing the code, it throws a System.PlatformNotSupportedException.

So I rebuilt the C# code for .NET Framework 4.8, adjusted the Python code accordingly, and the same code executes fine.

My theory is that there is some kind of .NET Framework dependency embedded in the SqlClient library that usually works fine inside of .NET 5. But wrapping it in Python.Net somehow breaks this. Does anyone have a good explanation for why I'm seeing this behavior?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source