Visitar URL original
PythonEngine.Shutdown() Crash · Issue #2107 · pythonnet/pythonnet · GitHub
Skip to content

PythonEngine.Shutdown() Crash #2107

Description

@nlogozzo

Environment

  • Pythonnet version: 3.0.1
  • Python version: 3.7.3
  • Operating System: Windows 11 (Same happens when running on WSL - Ubuntu)
  • .NET Runtime: .NET 7

Details

Calling Python.Runtime.PythonEngine.Shutdown(); results in the error:

System.NotSupportedException: 'BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information.'

Activity

  1. changed the title [-]PythonEngine.Shutdown() Error[/-] [+]PythonEngine.Shutdown() Crash[/+] on Feb 20, 2023
  2. added this to the 3.0.2 milestone on Feb 23, 2023
  3. filmor commented on Feb 23, 2023

    @filmor
    Member

    Workaround here: #2008 (comment)

  4. lostmsu commented on May 3, 2023

    @lostmsu
    Member

    @filmor do we even need Shutdown on .NET Core?

  5. modified the milestones: 3.0.2, 3.0.3 on Aug 29, 2023
  6. filmor commented on Sep 23, 2023

    @filmor
    Member

    We need to call Shutdown (in my opinion) just as well to ensure that destructors run in a sensible order. What we definitely don't need to do is the stashing part. It only needs to run if we want to reload domains, which is not supported on .NET Core anyway. I'm currently working on this (and related slowness during shutdowns) here:

    #2245

  7. JKingas commented on Jun 4, 2024

    @JKingas

    I recently tried pythonnet in C# Console Application in Visual Studio 2022.

    Environment

    • Pythonnet version: 3.0.3
    • Python version: 3.12.3
    • Operating System: Windows 11 23H2
    • .NET Runtime: .NET 8

    For now, Shutdown is needed, because without it, one of the threads does not allow the process to end completely.
    Then I tried to call Shutdown but got this exception in the PR.

    In this case, need to add <EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization> to the project file. Even with this flag, the process does not terminate without Shutdown.

    And after this flag and call Shutdown the process ends correctly.

  8. filmor commented on Sep 19, 2024

    @filmor
    Member

    This should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions