I have run my C# program importing MessageBox functions and other
win32 functions and it's all ok.
Now I want to create from VS2005 a dll in C++ that can be imported
from C#.
I've created an empty Win32 C++ project with dll target type.
These are my source files:
-------------- START ProvaDll2.cpp--------------
#include "stdafx.h"
#ifdef _MANAGED
#pragma managed(push, off)
#endif
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call,
LPVOID lpReserved)
{ return TRUE; }
extern int fnProvaDll(void)
{ return 17; /* rhis is the only row I edit from template */ }
#ifdef _MANAGED
#pragma managed(pop)
#endif
-------------- END ProvaDll2.cpp--------------
-------------- START stdafx.h--------------
....
// TODO: reference additional headers your program requires here
extern int fnProvaDll(void);
-------------- END stdafx.h--------------
I build it and it is all ok (obviously, it is empty ...)
Then I build my C# project, after having copied the compiled dll in
the debug dir
-------------- START Program.h --------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace ConsoleApplicationDll
{
class Program
{
[DllImport("ProvaDll2")]
public static extern int fnProvaDll();
static void Main(string[] args)
{
int k = fnProvaDll(); // <-EntryPointNotFoundException
}
}
}
-------------- END Program.h --------------
and it gives me an EntryPointNotFoundException.
The dll has been succesfully loaded (it is not a path problem) but the
entry point is not found.
What I'm missing?
Thanks,
Matteo