You need to be very specific about name mangling and calling convention
options. On the C++ side, you probably want:
#define FOREXPORT __declspec( dllexport ) __stdcall extern "C"
Use Dependency Walker (
www.dependencywalker.com) to view the export table,
then you have the option of viewing the raw names or the decoded C++ names.
You will probably also want a linker definition file (.def) to avoid name
mangling completely.
"Koliber (js)" <pr************ **@poczta.onet. plwrote in message
news:11******** **************@ o61g2000hsh.goo glegroups.com.. .
On 7 Sie, 19:19, Arne Vajhøj <a...@vajhoej.d kwrote:
Koliber (js) wrote:
does anybody could tell me how can i do a 'simple c++ dll I compiled'
- calling
from my c# code (when I try adding this dll to references' it ays that
it should be com) ?
If the DLL is a normal Win32 DLL and not a COM/ActiveX DLL, then
you need to DllImport the functions you want to use.
Note that I said functions not classes and methods.
Arne
I tried some like this in cpp dll
#define DllExport __declspec( dllexport )
/DllExport extern void test();
DllExport extern int a();
DllExport extern int b();
/
*************** *************** *************** *************** *************** **/
void test()
{
}
int a()
{
return 6;
}
int b()
{
return -6; //676k6
}
and in c# code:
using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Runtime. InteropServices ;
namespace ConsoleApplicat ionTest
{
class Program
{
[DllImport("dng_ validate.dll")]
public extern static void test();
[DllImport("dng_ validate.dll")]
public extern static int a();
[DllImport("dng_ validate.dll")]
public extern static int b();
static void Main(string[] args)
{
test();
b();
a();
}
}
}
but in runtime there is an error that in my dll there is no entry
point test
(also a b tried) There is if i check it with total commander plugin
exported functions are:
int __cdecl a(void)
int __cdecl b(void)
int __cdecl test(void)
:( ?
T I A
JS