المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : C# to MATLAB connectivity in windows 7



C# Programming
07-02-2011, 12:00 AM
Hello,
I am trying to connect c# with MATLAB. I used the deploytool in MATLAB to get the dll file to be used in my c# application. I followed the steps by step example from
MATHWORKS tells for its connectivity with c# (http://www.mathworks.com/help/toolbox/dotnetbuilder/ug/brys492-1.html)[^ (http://www.mathworks.com/help/toolbox/dotnetbuilder/ug/brys492-1.html)].

After building my c# project, when I run, it stops working and shows run time exception as follows:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'test.testclass' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT:0x8007000B)
at MathWorks.MATLAB.NET.Utility.MWMCR.mclInitializeApplication(String[] start
upOptions, Int32 startupOptionsCount)
at MathWorks.MATLAB.NET.Utility.MWMCR.InitializeApplication(String[] startupOptions)
at test.testclass..cctor()
--- End of inner exception stack trace ---
at test.testclass..ctor()
at mainApp_test.Program.Main(String[] args) in C:\Users\Abro\Documents\Visual
Studio 2008\Projects\mainApp_test\mainApp_test\Program.cs:line 44
Press any key to continue . . .

Can anyone help me solving this problem?

I am using MATLAB version 7.3, visual studio 8, windows 7 home premium, 64-bit operating system

my c# code is:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using test;
using MathWorks.MATLAB.NET.Arrays;
using MathWorks.MATLAB.NET.Utility;


namespace mainApp_test
{
class Program
{
static void Main(string[] args)
{
testclass obj = null;
double[] a = new double[1] { 10 };
double[] b = new double[1] { 33 };
MWNumericArray mwnA = new MWNumericArray(a);
MWNumericArray mwnB = new MWNumericArray(b);
MWArray[] result =null;
try
{
obj = new testclass();
result = obj.addMatlab(mwnA,mwnB);
MWNumericArray output = (MWNumericArray)result.ToArray();
Console.WriteLine(output);
}
catch(Exception)
{
throw;
}
}
}
}