使用visual studio C#2005编写的代码在visual studio C#2010中不起作用



我目前正在编写由人们使用visual studio C#2005编写的代码。当我在visual studio C#2010中运行代码后,这个窗口弹出,上面写着:

Unhandled exception has occurred in your application. If you click Continue.the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.
An attempt was made to load a program with an incorrect format.(Exception from HRESULT:0x8007000B)
***************Exception Text********
System.BadImageFormatException: An attempt was made to load a program with an incorrect format.(Exception from `HRESULT:0x8007000B`)
at PvNET.Pv.Initialize()
at Camera TestApp.CamMeasurement.PVInitialize(Measurement Type measurement) in C:...
at Camera TestApp.PTCMeasurement,PTCMeasurement_Load(Object sender. EventArgs e) in 
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Control.CreateControl(Boolean flgnore Visible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message&m)
at System.Windows.Forms.Control.WindProc(Message&m)
at System.Windows.Forms.Form.WmShowWindow(Message&m)
at System.Windows.Forms.Form.WindProc(Message&m)
at System.Windows.Forms.NativeWindow.Callback(lntPtr hWind. lnt32msg. lntPtr wparam,lnt Ptr lntPtr lparam)
**********Loaded Assemblies********

我不知道怎么解决这个问题。有人能告诉我这个问题的原因吗?

假设最初的程序员不是在64位操作系统上开发代码的,所以使用默认的项目设置是非常安全的。并且"CamMeasurement"是仅在32位模式下工作的非托管代码。

右键单击EXE项目,属性,编译选项卡。将目标平台设置从"AnyCPU"更改为"x86"。

您的程序可能只使用32位的本机DLL(在32位版本的Windows或只安装.NET 32位的PC上不是问题)。

您必须转到exe项目的属性,并在Build选项中将目标CPU从AnyCPU更改为x86

最新更新