Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
First steps with Python.NET
#11
I have run into problems with PythonNET recently following the upgrade from C# 8 to C#9 (I think). I've had this error code pop up (actually in other C# projects as well):
 
Code:
Copy      Help
System.PlatformNotSupportedException: BinaryFormatter serialization and deserialization have been removed. See https://aka.ms/binaryformatter for more information.

I believe there were severe security issues with the BinaryFormatter that resulted in it being removed. At the moment, I've simply been deleting references to 'PythonEngine.Shutdown()' from @Gintaras's class, and the error goes away. I still use the following, however:
 
Code:
Copy      Help
PythonEngine.Initialize();
using (Py.GIL()) {
   // do stuff
    
    dynamic scope = Py.CreateScope();
  // do stuff with scope
    Py.GIL().Dispose();
}

@Gintaras may have a better way to do this, of course.
Best regards,
burque505


Messages In This Thread
First steps with Python.NET - by burque505 - 06-17-2023, 09:16 PM
RE: First steps with Python.NET - by burque505 - 06-17-2023, 10:23 PM
RE: First steps with Python.NET - by Gintaras - 06-18-2023, 05:58 AM
RE: First steps with Python.NET - by burque505 - 06-18-2023, 12:27 PM
RE: First steps with Python.NET - by Gintaras - 08-01-2023, 06:38 PM
RE: First steps with Python.NET - by Gintaras - 08-01-2023, 06:40 PM
RE: First steps with Python.NET - by burque505 - 08-01-2023, 07:42 PM
RE: First steps with Python.NET - by Davider - 01-29-2024, 01:10 AM
RE: First steps with Python.NET - by Gintaras - 01-29-2024, 09:15 AM
RE: First steps with Python.NET - by Davider - 01-29-2024, 01:49 PM
RE: First steps with Python.NET - by burque505 - 05-16-2025, 09:41 PM
RE: First steps with Python.NET - by Gintaras - 05-19-2025, 04:27 PM
RE: First steps with Python.NET - by Davider - 06-09-2025, 08:39 AM
RE: First steps with Python.NET - by Gintaras - 06-09-2025, 09:48 AM
RE: First steps with Python.NET - by Davider - 06-09-2025, 09:56 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)