Python for .NET “unable to find assembly” error

前端 未结 6 1758
情书的邮戳
情书的邮戳 2020-12-10 11:42

I\'m using CPython and I have a C# dll. I\'m trying to use Python for .NET to make them talk. I can\'t use IronPython because I need to integrate this into an existing CPy

6条回答
  •  借酒劲吻你
    2020-12-10 11:59

    I have code like this (I copied MyRightClickMenuService.dll to the same directory as my script.py). It is built against .Net 4.0.

    # script.py
    import clr
    import os
    import sys
    sys.path.append(os.path.dirname(__file__))
    
    clr.AddReference('MyRightClickMenuService')
    clr.AddReference('System')
    clr.AddReference('System.Security')
    
    from MyRightClickMenuService import (
        AclSecuredNamedPipeBinding,
        MyMenuItem,
        MyContextMenuService,
        etc
    )
    

提交回复
热议问题