1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Calling windows-targeted .NET dll using pythonnet

Discussão em 'Python' iniciado por Stack, Abril 1, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to call my C# library from python like so:

    import sys
    import clr

    dll_path = r"/path/to/dll/folder"
    sys.path.append(dll_path)

    clr.AddReference("PyCsLib") # <- always passes

    from PyCsLib import TestClass # <- raises an error when targeting net9.0-windows10.0.17763


    When the C# project TargetFramework is net9.0, it works fine. However, when I switch to net9.0-windows10.0.17763, the python code fails on import:

    ModuleNotFoundError: No module named 'PyCsLib'


    Did I miss something? Or is pythonnet not compatible with such target?

    Continue reading...

Compartilhe esta Página