Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have prepared a simple matlab code and deployed it by means of deployment procedure in matlab in ".Net assembly" type (for use in C#.net 2010). The output Dll file of matlab was named "main". But that error occurs. I have added references.
What I really want is to define variables and give values to them in C# environment, calculate the outputs in Matlab Dll file, and finally show the results in C#.

Matlab Code:
C++
function c=main(a,b)
c=a+b;
end

C# code:
C#
namespace WindowsFormsApplication1
{
public partial class form1.form
{
[DllImport("main.dll")]
public static extern int main (int a, int b);

public form1()
{
InitializeComponent();
}
private void button1_click(object sender, EventArgs e)
{ 
int a,b,c;
a=convert.toint16(textbox1.text);
b=convert.toint16(textbox2.text);
c=main(a,b);
textbox3.text=c.ToString();
}
}
}
Posted
Updated 7-Oct-12 2:00am
v5
Comments
[no name] 7-Oct-12 6:51am    
First thing: Do not post your email. It's an invitation to spammers. Second thing: public static extern int (int a, int b); is wrong.
Hadi Farahani 7-Oct-12 7:53am    
You are OK. I forgot it. I have added "main" to that line of code.
Richard MacCutchan 7-Oct-12 7:47am    
Third thing, don't call a library function main(), as it will conflict with any main method in your application or the framework.

1 solution

Hello,

That article will helps you:

1..2..3 ways of integrating MATLAB with the .NET[^]

Regards,
Maxim.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900