主要目标:为可在Python(2.6)中使用的C#库创建包装器。在Python中为C#库创建包装器
更新:现在,我对我正在使用的方法进行了更新,但该方法运行不正常。
了简单的C#类库代码:
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace Test
{
[Guid("8F38030D-52FA-4816-B587-A925FDD33302")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface _TestClass
{
[DispId(1)]
string Eureka();
}
[Guid("BC3F6BB3-42C4-4F30-869A-92EA45BF68D2")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("Test.TestClass")]
public class TestClass : _TestClass
{
public TestClass()
{
}
public string Eureka()
{
return "Hudson, we no longer have a problem!";
}
}
}
enter code here
除了这个,我走进项目属性和启用该设置:注册COM互操作。
此外,为了使COM库可用,我打勾签署 - >签署大会,并给它一个强大的关键。
此外,每当我编译,我注销旧版本:
regasm -u Test /tlb:Test
和我一起进行注册:
regasm Test.dll的/ TLB:测试
我的问题是,在Python环境中,我有以下main.py,它不工作:
import win32com.client
o = win32com.client.Dispatch("Test.TestClass")
错误是不可宽恕的。
谢谢你提前!
可能重复(http://stackoverflow.com/questions/2077870/how-to-load-ac-dll-in-蟒蛇) –
我读过,这是相同的话题,但我没有搞清楚我的问题。 –