Howdy,
I've worked through the few threads on this issue in the group archives
but still not quite getting where i need to be. Other than whacking
around some MUD code a few years ago, this is my first time with C++.
Working in VS.net 2k3, my solution has a C# project and a C++ project.
In C++ I have a public function in a class exported from the project
dll.
In the VS class view, I have
cppProject
|--{}cppNamespace
|--cppClass
|--cppFunction
and I added cppProject.dll to the C# project references. In my C#, I
type "cppNamespace." and intellisense will list the cppClass. I figure
that's a good sign.
So again in C#, I have "cppClass myClass = new cppClass();" but that's
a far as I get. There's doesn't seem to be any recognition of
cppFunction in cppClass. I get a lot of "'cppNamespace.cppClass' does
not contain a reference for 'cppFunction'" errors.
Any thoughts on what I'm missing? All suggestions most appreciated.
TIA,
Sean G
scottelloco@gmail.com - 18 Mar 2006 00:36 GMT
Sean,
First, your function in your C++ app will need to be a "C" function.
You can place the decorated name in the header for your C++ class. For
example:
extern "C"
{
CEDB_API bool LoadProcedure();
}
Is the C++ project a dll? If so, then you'll need to add a dll imfort
for each function you want to call in your C++ dll., like this:
[DllImport("CedbXml", CharSet = CharSet.Auto)]
public static extern bool LoadProcedure();
Let say you place your DllImport statement in a C# class called
CppApi... you'll then be able to call your C++ function liek so:
bool result = CppApi.LoadProcedure();
SeanGerman@gmail.com - 20 Mar 2006 23:21 GMT
Thank you! Exactly what I was looking for.
I had to specify an EntryPoint, but then it was off and running.
Thanks again,
Sean G.