From: Dan Piraner on
Hello,

I'm trying to learn how to integrate MatLab code into C#. I'm using Matlab R2010a and Visual Studio 2010. I downloaded the following tutorial and executed the MatLab side of the code:

http://www.mathworks.se/matlabcentral/fileexchange/12987

However, when I tried to compile the C# code in visual studio, I got the following error:
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.

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

http://www.mathworks.com/support/solutions/en/data/1-B0JOFC/index.html?solution=1-B0JOFC

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

System.BadImageFormatException was unhandled

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."

Another google search led me to this page, which said that components generated by MatLab builder x86 are not supported on x64 machines:

http://www.mathworks.com/support/solutions/en/data/1-7457HL/index.html?product=MN&solution=1-7457HL

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