900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 加载c# .Net动态库

加载c# .Net动态库

时间:2022-09-25 19:23:58

相关推荐

加载c# .Net动态库

使用工具:Pythonnet, target.dll

Dllcode:

namespace TestNS

{

public class Test

{

public int Add(int a, int b)

{

return a + b;

}

}

}

Python Examples:

确保dll已经在项目的搜索路径中,若不在,使用sys.path添加

clr.AddReference(“target”)

from TestNS import Test

test = Test()

test.Add()

调试方法:

dll_ref = System.Reflection.Assembly.LoadFile(dll_path)

print(dll_ref.FullName)

print(dll_ref.Location)

for i in range(len(dll_ref.DefinedTypes)):

print(dll_ref.DefinedTypes[i])

上述代码可查看dll所包含内容及导入异常代码

.Net异常原因分析:

https://airbrake.io/blog/dotnet-exception-handling/system-badimageformatexception

Pythonnet使用指南链接

/pythonnet/pythonnet/wiki

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。