c# - 如何在 ctypes 库 python 中获取我的 C# dll 的依赖关系?
问题描述
我想在 python 应用程序中使用 .net framework 4.7 运行 C# dll。我在 dll 中为我的方法使用 dllExport nuget,因为 ctypes 以这种方式访问我的方法。样本:
using System.Runtime.InteropServices;
namespace MyNameSpace
{
public class MyClass
{
[DllExport("MyMethod", CallingConvention = CallingConvention.StdCall)]
public static int MyMethod(int a,int b)
{
return a + b;
}
}
}
在蟒蛇中:
def myFunction():
Dllpath = os.path.join("dll folder directory")
os.add_dll_directory(Dllpath + r"myDll.dll")
# WinDll used just windows os, in Linux is different
lib = WinDLL(Dllpath + r"myDll.dll")
lib.MyMethod(12,17)
这是工作。
但是当我在我的 dll 中使用其他库(dll)时,我得到了这个错误:
[WinError -532462766] Windows Error 0xe0434352
我猜这个错误是因为我的dll依赖问题。
如何解决此错误?
解决方案
您也应该将“DllExport”放在您在所有依赖项中调用的所有函数之上。
推荐阅读
- automata - 具有 4 或 5 个状态的 DFA
- javascript - 多个 Shopify 布局脚本 - “脚本”和“javascript”类型
- wordpress - 如何更改移动 wp_query 中的帖子计数?
- sql - Netsuite 保存的搜索在自定义列上找到 0 并查看其间的天数
- typescript - 为什么我的减速器仍然在我的测试用例中设置无效输入的状态?
- amazon-web-services - 在 AWS Server-less 应用程序中,电子邮件微服务的架构应该是什么样子
- html - 为移动设备按列订购 Bootstrap Grid
- html - 删除使用 Bash 在 HTML 文件中的 a 中的标签
目标是仅在 HTML 文件中的
<div>
和之间删除和的实例。标签之外的所有标签都将保留。里面标签内的内容也将保留。</div>
<table>
</table>
<div>...</div>
<t
- sql - SQLite 查询格式
- hyperledger - Hyperledger Indy - VON 网络错误 - 初始化池分类帐时出错