I am writing a C++ library. I know that I can export classes through
dllexport keyword. However, we also need this library to be accessible from
.Net applications. Our original plan is to package it using COM. Is there a
way to expose these classes without adding COM layer? Thanks
>I am writing a C++ library. I know that I can export classes through
>dllexport keyword. However, we also need this library to be accessible from
>.Net applications. Our original plan is to package it using COM. Is there a
>way to expose these classes without adding COM layer? Thanks
Yes, you can use a C++ Interop (or you can use PInvoke directly) to interact
with unmanaged code that uses dllexport.
You can read more about it here:
http://msdn2.microsoft.com/en-us/library/2x8kf7zx(vs.80).aspx
A newsgroup that is dedicated to this subject is
microsoft.public.dotnet.framework.interop.
HTH,
Brian
Alexander Nickolov - 12 Jun 2007 18:06 GMT
Brian, are you sure P/Invole supports non-C DLL exports?

Signature
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
>>I am writing a C++ library. I know that I can export classes through
>>dllexport keyword. However, we also need this library to be accessible
[quoted text clipped - 13 lines]
>
> Brian
Brian Muth - 12 Jun 2007 19:24 GMT
> Brian, are you sure P/Invole supports non-C DLL exports?
I think it has to be a C-style DLL export. Thanks for the clarification.
http://msdn2.microsoft.com/en-us/library/ms235282(VS.80).aspx
Frankly, I'd be inclined to put a COM wrapper around the C++ library. I'm
sure you feel the same way.
MrAsm - 12 Jun 2007 20:21 GMT
>Frankly, I'd be inclined to put a COM wrapper around the C++ library. I'm
>sure you feel the same way.
I agree that the more robust way to reuse C++ libraries is wrapping
using COM. e.g. a DLL which exports C++ classes, built with
VS.NET2003, may have problems if used (without rebuilding) with
VS2005. If the C++ library has a COM wrapper around, those problems do
not exist.
COM is really a very good technology for binary code reuse, IMHO.
MrAsm