C#调用VC dll 出现“System.BadImageFormatException”
来源:互联网 发布:卖家如何申请淘宝介入 编辑:程序博客网 时间:2024/05/29 04:17
namespace Hello_seesharp
{
class Program
{
[DllImport("Read-WriteString.dll", EntryPoint = "Add",
ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int Add(int a, int b);
static void Main(string[] args)
{
int c = Add(3, 2);
Console.WriteLine("hello,world");
Console.Write(c);
Console.Read();
}
}
{
class Program
{
[DllImport("Read-WriteString.dll", EntryPoint = "Add",
ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int Add(int a, int b);
static void Main(string[] args)
{
int c = Add(3, 2);
Console.WriteLine("hello,world");
Console.Write(c);
Console.Read();
}
}
}
在调试程序时,出现如下错误,(前提Read-WriteString.dll已放到bin目录下面)。
“System.BadImageFormatException”类型的未经处理的异常出现在 Hello-seesharp.exe 中。
其他信息: 试图加载格式不正确的程序。 (异常来自 HRESULT:0x8007000B)
经检查发现,原来编写vc dll时用的是x86平台,即32位
而编译C#时用的x64, 即64位
我们可以将C#切换到x86平台编译,编译通过。
- C#调用VC dll 出现“System.BadImageFormatException”
- C# 调用 dll 报错 System.BadImageFormatException:
- c#下出现“”未处理System.BadImageFormatException“错误
- C#中System.BadImageFormatException解决
- c#调用vc的dll (参数有LPSTR) 出现乱码!
- asp.net mvc 调用C++编写的64位的dll引发System.BadImageFormatException
- VC调用C#的DLL
- VC 调用C# DLL总结
- vc mfc 调用C# dll
- 处理c#调用c++dll所引起的“找不到指定模块"和BadImageFormatException异常
- 处理c#调用c++dll所引起的“找不到指定模块"和BadImageFormatException异常
- C# x64程序部署 System.BadImageFormatException异常
- System.BadImageFormatException
- System.BadImageFormatException:
- System.BadImageFormatException
- C#调用VC dll提供的接口
- vc 下调用C#的dll步骤
- VC调用C#的COM组件(DLL)
- CSS height=100%无效的解决方案
- 数据库的设计原则:关联还是不关联?
- Directsound开发指南(2)
- Skype Rc4最新算法下载地址
- MySQL完成解决ODBC中文乱码问题
- C#调用VC dll 出现“System.BadImageFormatException”
- Entity Framework 4 此操作要求连接到 'master' 数据库错误解决方案
- SharePoint 2007部署过程详细图解(下)— 部署MOSS 2007
- 语言的歧义
- 给孩子下载电子书的注意事项
- 获取Html元素在页面中的绝对位置及问题
- [andriod]四大组件之Service
- 函数模块:CTVB_COMPARE_TABLES
- Android 中调试手段 打印函数调用栈信息