How to use a C# dll in IronPython

后端 未结 6 784
轻奢々
轻奢々 2020-12-03 05:18

I have created a dll using C#. How do use the dll in IronPython. I have tried to add the dll using clr.AddReference(\"yxz.dll\"). But it fails. I have tried pla

6条回答
  •  爱一瞬间的悲伤
    2020-12-03 05:58

    import clr    
    clr.AddReferenceToFileAndPath(r"C:\Folder\Subfolder\file.dll")
    

    is the simplest way as proposed by Jeff in the comments. This also works:

    import clr
    import sys
    
    sys.path.append(r"C:\Folder\Subfolder")  # path of dll
    clr.AddReference ("Ipytest.dll") # the dll
    import TestNamspace  # import namespace from Ipytest.dll
    

提交回复
热议问题