nastoski
Technical User
- Oct 21, 2003
- 21
Dear all,
When trying to import C++ dll in C# I found a problem that can not solve. When calling dll method I get an error:
Unable to find an entry point named ‘add’ in DLL ‘cppdll.dll’
This is the example of the code:
DLL code in C++ (VS 2005)
cppdll.h
class __declspec(dllexport) Adder
{
public:
Adder(){;};
~Adder(){;};
int add(int x,int y);
};
cppdll.cpp
#include "cppdll.h"
int Adder::add(int x,int y)
{
return (x+y);
}
C# client program
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace callinglibrary
{
class Program
{
[DllImport("cppdll.dll")]
public static extern int add(int x, int y);
static void Main(string[] args)
{
int c;
c = add(5, 6);
}
}
}
Can you please help me and tell me what seems to be a problem.
Thanks in advance.
Regards
Igor Nastoski
When trying to import C++ dll in C# I found a problem that can not solve. When calling dll method I get an error:
Unable to find an entry point named ‘add’ in DLL ‘cppdll.dll’
This is the example of the code:
DLL code in C++ (VS 2005)
cppdll.h
class __declspec(dllexport) Adder
{
public:
Adder(){;};
~Adder(){;};
int add(int x,int y);
};
cppdll.cpp
#include "cppdll.h"
int Adder::add(int x,int y)
{
return (x+y);
}
C# client program
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace callinglibrary
{
class Program
{
[DllImport("cppdll.dll")]
public static extern int add(int x, int y);
static void Main(string[] args)
{
int c;
c = add(5, 6);
}
}
}
Can you please help me and tell me what seems to be a problem.
Thanks in advance.
Regards
Igor Nastoski