Visitar URL original
Drop support for .NET Framework 4.0 - 4.6 (e.g. require 4.6.1, which supports .NET Standard 2.0) · Issue #1299 · pythonnet/pythonnet · GitHub
Skip to content

Drop support for .NET Framework 4.0 - 4.6 (e.g. require 4.6.1, which supports .NET Standard 2.0) #1299

Description

@lostmsu

I propose we drop support for the older .NET Framework versions, that do not support .NET Standard 2.0. According to the official documentation this would leave us with:

  • .NET Framework 4.6.1+ (requires manual installation on Windows 8.X, Windows 10 1507 (the very first one), and Windows Server 2012 + R2)
  • .NET Core 2.0+
  • Mono 5.4+
  • Xamarin.Mac 3.8+
  • Unity 2018.1+

This should remove the xplat option, and a few polyfills as well as dependency on Python modules inside C# code in some cases (OS detection).

@filmor @amos402 @benoithudson @BadSingleton

Activity

  1. filmor commented on Dec 1, 2020

    @filmor
    Member

    .NET Standard before 4.7.2 has unfixed bugs, so that should be the target.

  2. lostmsu commented on Dec 1, 2020

    @lostmsu
    MemberAuthor

    Are any of those bugs important for us?

  3. benoithudson commented on Dec 1, 2020

    @benoithudson
    Contributor
  4. filmor commented on Dec 2, 2020

    @filmor
    Member

    Do you happen to know what the support-level of Unity 2019.4 is? Should be enough to know what Mono version is linked.

  5. benoithudson commented on Dec 2, 2020

    @benoithudson
    Contributor
  6. filmor commented on Dec 10, 2020

    @filmor
    Member

    With #1209 merged, we now test .NET 4.7.2 and .NET Standard 2.0. .NET Standard 2.0 is the hard requirement.

  7. Metadorius commented on Mar 6, 2026

    @Metadorius
    Contributor

    @filmor apologies for hijacking an old thread, can create a new issue if you want.

    Are there any actual blockers which prevent at least limited support of 4.6.1 as a part of .NET Standard 2.0?

    I needed that and while I know that 4.6.1/Standard 2.0 situation is messy in .NET in general, I've:

    1. patched CLR Loader to compile for net461 (LPUTF8Str -> IntPtr with manual conversion, ValueTuple -> Tuple),
    2. referenced ValueTuple and InteropServices in Python.Runtime.csproj,
    3. made a build step to copy netstandard.dll assembly to the OutDir,

    and only if I switch the target framework to net461 for Python.Runtime.csproj, then I am able to run a simple hello world successfully from Python in a 4.6.2 environment. If I switch target back to netstandard2.0 -- the assemblies disappear from the output, and even if I add them back - I for some reason get errors on loading them which I currently am not sure how to resolve:

    Failed to initialize pythonnet: System.TypeInitializationException: The type initializer for 'Delegates' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
       at Python.Runtime.Platform.LibraryLoader.get_Instance()
       at Python.Runtime.Runtime.Delegates..cctor()
       --- End of inner exception stack trace ---
       at Python.Runtime.Runtime.Delegates.get_PyGILState_Ensure()
       at Python.Runtime.Runtime.PyGILState_Ensure()
       at Python.Runtime.Py.GIL()
       at Python.Runtime.Loader.Initialize(IntPtr data, Int32 size)
       at Python.Runtime.Runtime.Delegates.get_PyGILState_Ensure()
       at Python.Runtime.Runtime.PyGILState_Ensure()
       at Python.Runtime.Py.GIL()
       at Python.Runtime.Loader.Initialize(IntPtr data, Int32 size)
    

    I am not sure how to properly make netstandard2.0 assembly to reference and copy those DLLs properly for running on 4.6.1, would appreciate some insight on what I am doing wrong.

    If this is reasonably solvable, will there be opposition to allowing 4.6.1 (with a strong recommendation to update to 4.7.2) potentially, if, say, I submit the PR fitting the requirements?

    Also, outside of that, are there any blockers for going even lower theoretically (if I don't need to support anything else than .NET Framework)? Not as a part of the upstream/mainline.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions