【发布时间】:2022-11-18 17:46:48
【问题描述】:
我正在使用 pythonnet 将 C# dll 导入 python。
import sys
import clr
assemblydir = r"C:\Users\Nathan_Dehnel\source\repos\TFSHygiene\bin\Debug\net5.0-windows"
sys.path.append(assemblydir)
clr.AddReference("TFSHygiene")
from TFSHygiene import QueryExecutor
DLL 位于 assemblydir 中。
TFSHygiene 内部:
namespace TFSHygiene
{
public class QueryExecutor
{
...
}
}
我按照这个问题的答案:"No module named" error when attempting to importing c# dll using Python.NET
但是我在构建时收到此错误:
Traceback (most recent call last):
File "C:\Users\Nathan_Dehnel\OneDrive - Dell Technologies\Documents\ADO TFS\ADO TFS\main.py", line 12, in <module>
from TFSHygiene import QueryExecutor
ModuleNotFoundError: No module named 'TFSHygiene'
使用 .NET 5.0 目标构建。
【问题讨论】:
标签: python c# python-import .net-5 python.net