I am trying to import a c++ dll into my C# windows project. But i am
getting an error "Unable to find an entry point named 'Add' in DLL
'Test.dll'"
My c++ source code:
#pragma once
using namespace System;
namespace Test {
public ref class Class1
{
public: int Add(int i, int j)
{
return(i + j);
}
};
}
My C# windows source code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Test;
namespace WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("Test.dll")]
public static extern int Add(int a, int b);
private void button1_Click(object sender, EventArgs e)
{
int p = Add(1, 2);
}
}
}
I placed the c++ dll in c# application output path i e debug folder.
Please help to find me the error i made in the c++ or c# code.