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):
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:
@Gintaras may have a better way to do this, of course.
Best regards,
burque505
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:
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