You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want use python in dotnet ,but this dotnet evenment can not exit ,so i use func shutdown,but the C# evenment have an Exception:System.AggregateException: One or more errors occurred. (BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information.)
---> System.NotSupportedException: BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information.
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
at Python.Runtime.RuntimeData.Stash() in D:\work\vsprj\HDC_Instrament2024new\HDC_InstramentForPythonTkinter\pythonnet-master\src\runtime\StateSerialization\RuntimeData.cs:line 96
at Python.Runtime.Runtime.Shutdown() in D:\work\vsprj\HDC_Instrament2024new\HDC_InstramentForPythonTkinter\pythonnet-master\src\runtime\Runtime.cs:line 272
at Python.Runtime.PythonEngine.Shutdown() in D:\work\vsprj\HDC_Instrament2024new\HDC_InstramentForPythonTkinter\pythonnet-master\src\runtime\PythonEngine.cs:line 392
//功能测试booltaskrun=true;Task.Run(async()=>{// install in local directoryInstaller.InstallPath=Path.GetFullPath(".");// see what the installer is doingInstaller.LogMessage+=Console.WriteLine;boolloadend=false;awaitInstaller.SetupPython();if(!Installer.IsPipInstalled()){awaitInstaller.TryInstallPip();}if(!Installer.IsModuleInstalled("numpy")){awaitInstaller.PipInstallModule("numpy");}loadend=true;while(!loadend);PythonEngine.Initialize();try{// call Python's sys.version to prove we are executing the right versiondynamicsys=Py.Import("sys");Console.WriteLine("### Python version:\n\t"+sys.version);// call os.getcwd() to prove we are executing the locally installed embedded python distributiondynamicos=Py.Import("os");Console.WriteLine("### Current working directory:\n\t"+os.getcwd());Console.WriteLine("### PythonPath:\n\t"+PythonEngine.PythonPath);dynamicnp=Py.Import("numpy");// 导入numpy模块dynamicsin=np.sin;int[]data=newint[]{0,1,2,3};vara=np.array(data);varresult=sin(a);Console.WriteLine("Numpy sin:");Console.WriteLine(result);dynamictkinter=Py.Import("tkinter");// 导入tkinter模块vartop=tkinter.Tk();// 进入消息循环top.mainloop();}catch(PythonExceptione){Console.WriteLine($"{e}");}PythonEngine.Shutdown();}).ContinueWith((e)=>{Console.WriteLine($"{e.Exception}");taskrun=false;});while(taskrun);
If there was a crash, please include the traceback here.
Oneor more errors occurred.(BinaryFormatterserialization and deserialization are disabled within thisapplication.Seehttps://aka.ms/binaryformatter for more information.)---> System.NotSupportedException: BinaryFormatter serialization and deserialization are disabled within thisapplication.Seehttps://aka.ms/binaryformatter for more information.
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(StreamserializationStream,Objectgraph)at Python.Runtime.RuntimeData.Stash()inD:\work\vsprj\HDC_Instrament2024new\HDC_InstramentForPythonTkinter\pythonnet-master\src\runtime\StateSerialization\RuntimeData.cs:line 96
at Python.Runtime.Runtime.Shutdown() in D:\work\vsprj\HDC_Instrament2024new\HDC_InstramentForPythonTkinter\pythonnet-master\src\runtime\Runtime.cs:line 272
at Python.Runtime.PythonEngine.Shutdown() in D:\work\vsprj\HDC_Instrament2024new\HDC_InstramentForPythonTkinter\pythonnet-master\src\runtime\PythonEngine.cs:line 392
The text was updated successfully, but these errors were encountered:
Environment
Details
Describe what you were trying to get done.
I want use python in dotnet ,but this dotnet evenment can not exit ,so i use func shutdown,but the C# evenment have an Exception:System.AggregateException: One or more errors occurred. (BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information.)
---> System.NotSupportedException: BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information.
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
at Python.Runtime.RuntimeData.Stash() in D:\work\vsprj\HDC_Instrament2024new\HDC_InstramentForPythonTkinter\pythonnet-master\src\runtime\StateSerialization\RuntimeData.cs:line 96
at Python.Runtime.Runtime.Shutdown() in D:\work\vsprj\HDC_Instrament2024new\HDC_InstramentForPythonTkinter\pythonnet-master\src\runtime\Runtime.cs:line 272
at Python.Runtime.PythonEngine.Shutdown() in D:\work\vsprj\HDC_Instrament2024new\HDC_InstramentForPythonTkinter\pythonnet-master\src\runtime\PythonEngine.cs:line 392
What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
The text was updated successfully, but these errors were encountered: