- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我已经阅读了几个与我相关的问题,但没有一个对我有用。
我需要从非托管 DLL 调用函数。我在 SysWow64 中有 DLL 的 32 位版本,在 system32 中有 64 位版本。无论如何,我正在为 x86 编译。我没有 DLL 的源代码,因此无法使用 extern "C"重新编译。
DLL 包含文件的相关部分:
(...)
#include <string>
namespace SomeNamespace
{
(...)
typedef std::wstring STRING;
(...)
class SomeClass
{
(...)
static bool SomeFunc(const STRING& p1, bool p2);
(...)
}
}
调用 SomeFunc 时出现异常:“找不到名为‘?’的入口点在 DllName.dll 中”(翻译是我的,可能不准确)。
我在 C# 中的声明:
[System.Runtime.InteropServices.DllImport("DllName.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "?SomeFunc@SomeClass@SomeNamespace@@SA_NABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@_N@Z")]
bool SomeFunc(string p1, bool p2);
我也试过以下方法:
[System.Runtime.InteropServices.DllImport("DllName.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "#15")]
bool SomeFunc(string p1, bool p2);
15是根据Depends的函数序号,第一个版本中的EntryPoint也是从Depends中获取的。
根据undname.exe,这是函数的原始声明:
public: static bool __cdecl SomeFunc(class ?? :: ?? ::Z::basic_string<wchar_t,str
uct std::char_traits<wchar_t>,class w::allocator<wchar_t>,td,bool> const &, ?? )
throw( ?? )
它似乎没有正确解析它; bool 应该是 FuncName 的参数,而不是 basic_string 的类型参数。但是,我不确定这只是 undname.exe 的解析错误还是更严重的问题。
我该如何解决?
更新:当使用函数的序号作为入口点时,我没有得到异常。我从 Form 的 Load 事件中调用它,在调试时,我失去了控制权。我的意思是,我正在调试 SomeFunc() 行上的光标,我按 F10,应用程序继续运行,就好像我没有调试一样。我没有收到 ThreadException 或 UnhandledException。
调用代码:
public bool CallSomeFunc()
{
try
{
SomeFunc("p1", true);
}
catch (Exception ex)
{
ex.ToString(); // I just use this to put a breakpoint while debugging.
}
return true;
}
结束更新
最佳答案
您需要 C++/CLI 作为包装器来从 C++ 类中调用方法。PInvoke 仅适用于全局导出函数。
看看C++/CLI wrapper for native C++ to use as reference in C# .
关于c# - 使用 DlImport、Entrypoint 从 C# 调用命名空间中的 C++ 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18075261/
这个问题在这里已经有了答案: How to pass ARG value to ENTRYPOINT? (5 个答案) 关闭 3 年前。 我试图将参数传递到我的 docker 入口点,但它失败了,这
我正在尝试使用以下方法初始化运行Postgres的容器 FROM postgres:9.6 COPY my.backup /docker-entrypoint-initdb.d/ 在我的Dockerf
我在尝试启动我的应用程序时看到以下错误... > css-modules@1.0.0 start /Users/johnnynolan/Repos/css-modules webpack && ope
当我运行时:docker run --name mongodb -p 27107:27107 mongo --noauth --bind_ip=0.0.0.0 我总是得到这个错误:error: exe
我需要在ENTRYPOINT [..]上运行以下命令: dotnet reportgenerator -reports:coverage.cobertura.xml -targetdir:Report
我在理解或看到将bash脚本用作Docker容器的切入点时遇到问题。我已经尝试了很多东西了大约5个小时。 即使从此official Docker blog,使用bash脚本作为入口点仍然不起作用。 D
我有一个没有 UI 的 GWT 实用程序模块(因此,没有从 com.google.gwt.core.client.EntryPoint 继承的类。当我尝试使用 GWT 1.7.1 编译此模块时,我收到
我试图了解 ENTRYPOINT 之间的差异在 Dockerfile 和 docker run --entrypoint 中. exec ENTRYPOINT的表格允许多个参数, # Source:
我有一个入口点,如下所示 ENTRYPOINT /usr/bin/java ... /usr/path/$FILE 我试图在启动容器时传递一个环境变量 -e FILE=myfile.txt 但是这个值
我想以root用户身份启动nginx和cron,以1001用户身份启动php-fpm。我怎样才能做到这一点?我以为我必须创建一个入口点脚本,在其中我使用su-exec并以root身份启动nginx和c
我已经研究过在WordPress docker镜像中添加WordPress插件,因为在研究中我发现可以在docker-entrypoint.sh文件中添加自定义插件。但是我无法在入口点文件中添加自定义
我必须遵循(简单的)Dockerfile: FROM microsoft/windowsservercore:latest SHELL ["powershell", "-Command", "$Err
我正在尝试使用 ENTRYPOINT,但每当我这样做时,我都会收到一个错误,因为 no such file or directory docker 文件: FROM ubuntu:18.04 COPY
我是Docker的新手。尝试使用Transmission建立小图像。 这是我的 Dockerfile : #base image FROM alpine:latest #install Transmi
有没有办法使用 Dockerfile 在容器停止时运行命令?或在 docker-compose.yml使用 Docker 撰写?本质上,我想要一个在容器导出上运行的命令(与 ENTRYPOINT 相对
我正在使用 Dockerfile 构建自定义图像.显然,新的运行工作正常,但是当我停止容器并重新启动它时 - 它没有启动并保持在 的状态0号导出 . 该图像由 apache2 和一堆用于 symfon
我正在运行以下命令来通过命令行设置入口点以使用此容器启动Nginx服务 root @ server:〜#docker run -it --entrypoint =“/ bin / bash /root
我想在我的 docker-entrypoint.sh 上运行几个脚本; 我的问题是它是否有任何区别,如果有,推荐的解决方法是什么,关于以下选项: 一个 . ${HOMEDIR}/myscript --
我在将环境变量导出到 docker 入口点文件时遇到了一些问题。 这是我的 docker 文件内容: FROM ubuntu:16.04 ADD entrypoint.sh . RU
我正在尝试设置一个 django 项目并对其进行 dockerize。 我在运行容器时遇到问题。 据我所知,abe 构建成功,但运行失败。 这是我得到的错误: ERROR: for web Canno
我是一名优秀的程序员,十分优秀!