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
On Feb 8, 10:42 am, Michael Nemtsev <nemt...@msn.comwrote:
Hello Beorne,
See therehttp://quickstart.developerfusion.co.uk/QuickStart/howto/doc/Interop/...
I recommend to intall .NET SDK to have all quickstarts local
BI've no experience with C# infoking functions from external unmanaged
Bdll.
BI have to do an interface driving a set of hw device using their
Bpropetary dll.
BIs there some simple tutorial explaining how to do it using VS2005?
BThe technology to use is pinvoke?
BThanks,
BMatteo
---
WBR, Michael Nemtsev [C# MVP]. Blog:http://spaces.live.com/laflour
team blog:http://devkids.blogspot.com/
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo