Configuration / .NET version setup #2362
-
I am just a few days into PythonNet and have run into some very peculiar issues which I think must be caused by some configuration or versioning mismatches. There are no direct config mismatch error messages, things just don’t work properly and throw exceptions. This is a ~5,000-line c# .dll. The c# test stub which works fine. The python test stub fails. Initially: I am running on .NET 6.0 because in .NET 8.0 the following import fails with “Module Not Found” (maybe this is a clue). Getting past this by using .NET 6.0, I find that although the .dll runs fine from the c# stub, it runs DIFFERENTLY from the python stub in very peculiar ways. Here is one exception: {"Could not load type 'System.Math' from assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.":"System.Math"} There are other failures throughout the .dll related to strings, etc. Where did the 4.0.0.0 come from? How do I set it properly to 6.0? BTW, I have the Visual Studio debugger working on the c# .dll while it is called from the Python. I’ve seen a few posts asking about this but they are stale. If there’s interest, I’d be happy to share what I did. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Check the docs. Foe backwards-compat reasons, we still default to .NET Framework, you have to cpnfigure pythonnet to load .NET Core. |
Beta Was this translation helpful? Give feedback.
-
That's the ticket... |
Beta Was this translation helpful? Give feedback.
Check the docs. Foe backwards-compat reasons, we still default to .NET Framework, you have to cpnfigure pythonnet to load .NET Core.