用asp.net网站MATLAB的DLL集成在64位机器给人异常 [英] MATLAB dll integration with asp.net website in 64 bit machine giving exception

查看:244
本文介绍了用asp.net网站MATLAB的DLL集成在64位机器给人异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有机管局问题:我已经创建了Matlab的功能,我想在 asp.net 使用
。 这是工作的罚款在 32位机器,但是当我将其传送到 64位的机器是不加工。

I have a a problem: I have created a function in Matlab which I want to use in asp.net.
It is working fine on a 32-bit machine but when I transfer it to a 64-bit machine it is not working.

asp.net 在一个网站上Matlab的DLL集成 64位机器给出了一个例外,但不在 32位机器。

Matlab-dll integration with asp.net website on a 64-bit machine gives an exception, but not on a 32-bit machine.

背景

我想学习如何将Matlab的code到C#。我用Matlab R2010a版本和Visual Studio 2010。我下载教程>并执行了Matlab部分的code。

I'm trying to learn how to integrate Matlab code into C#. I'm using Matlab R2010a and Visual Studio 2010. I downloaded a tutorial from the Matlab File Exchange and executed the Matlab part of the code.

然而,当我试图编译C#code在Visual Studio中,我得到了以下错误:

However, when I tried to compile the C# code in visual studio, I got the following error:

无法加载文件或程序集MWArray,版本= 2.9.1.0,文化=中性公钥= e1d84a0da19db86f或它的某一个依赖。该系统找不到指定的文件。

Could not load file or assembly 'MWArray, Version=2.9.1.0, Culture=neutral, PublicKeyToken=e1d84a0da19db86f' or one of its dependencies. The system cannot find the file specified.

一个快速谷歌搜索使我的这个MathWorks的页面,它指示我的目标处理器更改为86。

A quick google search led me to this mathworks page, which instructed me to change the target processor to x86.

然而,当我这样做,我收到一个新的错误:

However, as soon as I did so, I received a new error:

System.BadImageFormatException了未处理

System.BadImageFormatException was unhandled

消息=无法加载文件或程序集MWArray,版本= 2.0.0.0,   文化=中性公钥= e1d84a0da19db86f或它的一个   依赖性。有人企图使用​​不正确的加载程序   格式。

Message="Could not load file or assembly 'MWArray, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e1d84a0da19db86f' or one of its dependencies. An attempt was made to load a program with an incorrect format."

我的matlab版是64位的,但我仍然遇到此问题。有没有解决办法?

My MatLab version is 64 bit, but I am still encountering this problem. Is there a workaround?

推荐答案

尝试使用此

从C#创建的应用程序被编译为管理code,这使得它们独立于平台(如Java,例如)。因此,当你编译一个32位的机器上的一个C#应用程序,然后在64位计算机上部署它,它会在默认情况下,尽量为64位应用程序运行。然后,它将尝试找到的64位版本的MWArray.dll的,如果失败,则提到的错误将被显示。

Applications created from C# are compiled as managed code, which makes them platform independent (like Java, for example). Thus, when you compile a C# application on a 32-bit machine and then deploy it on a 64-bit machine, it will, by default, try to run as a 64-bit application. Then, it will try to find the 64-bit version of the MWArray.dll, and if it fails, the mentioned error will be shown.

要解决此问题,设置选项>目标平台属性 - - >生成。这将具有该应用程序将开始在32位模式的64位机器上的效果。

To work around this issue, set the option "Properties -> Build -> Platform target" to "x86" instead of "Any CPU" before compiling your C# application. This will have the effect that the application will start in 32-bit mode on the 64-bit machine.

这篇关于用asp.net网站MATLAB的DLL集成在64位机器给人异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆