OK, thanks for answer.
If I want create an API with a stright C interface,
can I use embeddedVC++?
And if not, whitch compiler you advice to use?
Thanks very much
> You can't. There is no interop way for managed code to directly P/Invoke a
> class in a native library. Your only option is to create a native API with
[quoted text clipped - 9 lines]
> >
> > Thanks
Yes, you can do that. You want to declare the functions (no classes!), as
extern "C", when the client of the DLL sees their declarations, so you need
to make sure to form the declarations correctly. Something like this:
headerfile.h:
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef BUILDING_THE_DLL_ITSELF
#define EXPORTMODIFICATION declspec(dllexport)
#else
#define EXPORTMODIFICATION declspec(dllimport)
#endif
EXPORTMODIFICATION int Function1(...);
EXPORTMODIFICATION int Function2(...);
#ifdef __cplusplus
}
#endif
This will pretty-much assure that you don't do anything 'bad', like try to
have two versions of the same function name with different parameters
(overloading the name), which is a C++-only capability. The
EXPORTMODIFICATION symbol helps to assure that, when you're actually
building the DLL, as opposed to some other module that just uses it, that
you're getting the right modifiers on the function to make it exported from
the DLL. When a client of the EXE is being built, you get a suitable
'external' reference to the function which should be resolved when you link
the EXE by linking with the import library for the DLL. It's easier to see,
when you do it, than it is to explain clearly in a newsgroup post
(obviously!)...
Paul T.
> OK, thanks for answer.
> If I want create an API with a stright C interface,
[quoted text clipped - 19 lines]
>> >
>> > Thanks
Cri++ - 07 Oct 2008 07:56 GMT
Hi,
maybe I explained bad.
I'm already able to export a functions in C++ and use it in VB.NET.
My question is: how to export a whole class?
Thanks

Signature
Cri++
> Yes, you can do that. You want to declare the functions (no classes!), as
> extern "C", when the client of the DLL sees their declarations, so you need
[quoted text clipped - 58 lines]
> >> >
> >> > Thanks
Chris Tacke, MVP - 07 Oct 2008 12:41 GMT
You can't. The marshaler cannot pass classes or class references - you have
to use a flat C API.

Signature
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
> Hi,
> maybe I explained bad.
[quoted text clipped - 73 lines]
>> >> >
>> >> > Thanks
Cri++ - 07 Oct 2008 12:55 GMT
OK,
I understand,
but, how can I create a flat C API?
Thanks

Signature
Cri++
> You can't. The marshaler cannot pass classes or class references - you have
> to use a flat C API.
[quoted text clipped - 76 lines]
> >> >> >
> >> >> > Thanks
Paul G. Tobey [eMVP] - 07 Oct 2008 16:06 GMT
Have you *read* any of the messages (Chris previously told you 100% clearly
that you can't export a class from C++ and use it from managed code; why
make us repeat ourselves)? I sent a whole example in my last message
showing the basic format. We know nothing about what this DLL is supposed
to do? You want us to design an interface for it? You export "some
functions" that are appropriate from the DLL, as I showed you before, and
then you call them from managed code. You can't export a class and I would
recommend that you not export data items. That's about as far as we can
help...
Paul T.
> OK,
> I understand,
[quoted text clipped - 88 lines]
>> >> >> >
>> >> >> > Thanks
Cri++ - 08 Oct 2008 13:15 GMT
I have read all the messages but maybe I had a misunderstanding.
Sorry and thanks anyway

Signature
Cri++
> Have you *read* any of the messages (Chris previously told you 100% clearly
> that you can't export a class from C++ and use it from managed code; why
[quoted text clipped - 100 lines]
> >> >> >> >
> >> >> >> > Thanks
Paul G. Tobey [eMVP] - 08 Oct 2008 16:03 GMT
Good luck.
Paul T.
>I have read all the messages but maybe I had a misunderstanding.
>
[quoted text clipped - 118 lines]
>> >> >> >> >
>> >> >> >> > Thanks