LTG01 / Software-

Software Source
3 stars 4 forks source link

PythonNet #1

Open alphagw opened 5 years ago

alphagw commented 5 years ago

您好,可否提供一下PythonNetTest.dll 的C#源码,我下载您这个dll导入的时候可以正常运行,但是自己写了一个测试的C#,并且生成Dll之后就会报错ModuleNotFoundError: ,想请教一下大神这是什么问题

clr.FindAssembly("PythonNetTest.dll")
# clr.AddReference("PythonNetTest")
from PythonNetTest import *
instance = Class1()
print(instance.AddShort(2, 3))

>>> output: 5

# 但是
clr.FindAssembly("LearningCsharp1.dll")
# clr.AddReference("LearningCsharp1")
from LearningCsharp1.HelloWorldApplication import *
instance = namespace_cl()
>>> Traceback (most recent call last):
  File "G:/test/bin/csharp_test.py", line 33, in <module>
    from LearningCsharp1.HelloWorldApplication import *
ModuleNotFoundError: No module named 'LearningCsharp1'

我的LearnCsharp1.dll源码如下:

using System;
namespace HelloWorldApplication
{
    /* 类名为 HelloWorld */
    class HelloWorld
    {
        /* main函数 */
        static void Main(string[] args)
        {
            /* 我的第一个 C# 程序 */
            Console.WriteLine("Hello World!");
            Console.ReadKey();
        }
    }
}
backkom commented 4 years ago

我感觉是生成的x86还是x64选错了