问题描述
using System;
namespace HelloWorldApp {
class Geeks {
static void Main(string[] args) {
// statement
// printing Hello World!
Console.WriteLine("Hello World!");
// To prevents the screen from
// running and closing quickly
Console.ReadKey();
}
}
}
我想从jupyter笔记本中的python调用它。 我正在使用pythonnet并尝试类似的方法
import clr
clr.AddReference(r'chello')
from HelloWorldApp import Geeks
my = Geeks()
my.Main()
FileNotFoundException: Unable to find assembly 'chello'.
at Python.Runtime.CLRModule.AddReference(String name)
解决方法
Zeroth,为了澄清一下,您实际上在编译C#吗?
首先,考虑到其中包含Main,程序集名称可能是chello.exe。
第二,根据文件系统的布局,您需要将目录添加到PATH环境变量中,或将完整路径传递到AddReference
。