通过包装器 dll 访问 Web 服务中的 X64 静态库
Accessing X64 Static library in webservice through Wrapper dll
我有一个静态库X64位。我创建了一个包装器并通过控制台应用程序执行,它工作正常。当我使用相同的包装器 dll 并尝试通过 Web 服务公开方法时,出现错误。
代码片段:包装纸
#include "Header.h"
#include "sonobox.hpp"
namespace MyWin32DLL
{
MyWin32ClassOne::MyWin32ClassOne()
{
varone = 123;
}
__declspec(dllexport) int MyWin32ClassOne::getoutput()
{
uikey=GetKey();
}
return uikey;
}
}
WEb服务:-
public class WebService1 : System.Web.Services.WebService
{
[DllImport("Win32Project2.dll", CharSet = CharSet.Unicode)]
public static extern int getoutput();
[WebMethod]
public int HelloWorld()
{
return getoutput();
}
}
错误:-无法加载文件或程序集"****"或其依赖项之一。尝试加载格式不正确的程序。
拜托嘻嘻!
此错误的最常见原因是位数不匹配。该过程为 32 位,故障程序集为 64 位。反之亦然。如果是这样,那么您有两种可能的解决方案:
- 使用 32 位
- 版本的静态库生成程序集的 32 位版本。
- 确保 Web 服务在 64 位进程中执行。
相关文章:
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- #为""定义宏;静态";针对不同的上下文
- cmake如何在fedora工作站中找到boost静态库包
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 将公共但非静态的成员函数与ALGLIB集成
- cmake在我的项目中所需的所有静态库都不成功
- C++从另一个类访问公共静态向量的正确方法是什么
- 基于boost的程序的静态链接——zlib问题
- 在静态库中嵌入类方法
- Qt C++静态thread_local QNetworkAccessManager是线程应用程序的好选择吗
- 如何在C++中获得"静态纯虚拟"功能?
- 私有类型的静态常量成员
- 使用gcc从静态链接的文件中查找可选符号
- 在 .h 文件中的类中声明静态变量和在.cpp文件中声明"global"变量有什么区别
- 如何在MSVS2015中为X64使用静态库
- 在编译期间混合 x86 和 x64 静态库C++
- 通过包装器 dll 访问 Web 服务中的 X64 静态库
- Linux x64下针对indigo cheminformatics包的静态链接会在使用Free Pascal时抱怨对_
- Qt5 - 静态 x64 和链接噩梦
- 你如何为 x64 编译静态 pthread-win32 库