VC++ COM-library compilation under .NET as managed code

M

Michael Braitmaier

I have a quite severe problem. I am trying to compile a C++ library
initially written for VC++ 6. To make the library available for .NET
languages I want to compile the library as managed C++ library. As the
library is utilizing DirectX 9 it bases on COM. This causes me quite some
troubles as I get compile errors caused by the include files included
through the DirectX 9 header file.
The errors occur in unknwn.h, objbase.h and ObjIdl.h.

For example:
Error 12 error C2079: 'IRpcStubBuffer' uses undefined
struct 'IRpcStubBuffer' I:\Programme\Microsoft SDK\include\ObjBase.h
398
Error 11 error C2146: syntax error : missing ';' before
identifier 'IRpcStubBuffer' I:\Programme\Microsoft SDK\include\ObjBase.h
398


Error 19 error C2146: syntax error : missing ';' before
identifier 'IClassFactory' I:\Programme\Microsoft SDK\include\Unknwn.h
60
Error 17 error C2146: syntax error : missing ';' before
identifier 'AsyncIUnknown' I:\Programme\Microsoft SDK\include\Unknwn.h
54
Error 15 error C2146: syntax error : missing ';' before
identifier 'IUnknown' I:\Programme\Microsoft SDK\include\Unknwn.h 48


Error 116 error C2146: syntax error : missing ';' before
identifier 'IMarshal2' I:\Programme\Microsoft SDK\include\ObjIdl.h
54
Error 114 error C2146: syntax error : missing ';' before
identifier 'IMarshal' I:\Programme\Microsoft SDK\include\ObjIdl.h 48


Overall the compiler throws about 200 error messages. I am compiling against
the include files contained in the VS.2005 Beta.
Strangely enough I once got it compiled under VS.NET 2002, but then I
missed generics which were not available then, which I hope work with VS2005
now. If someone could point me out a direction where to investigate for or
have an idea about how to solve this problem, that would be great.
Any help would be greatly appreciated.

Michael
 
C

Carl Daniel [VC++ MVP]

Michael said:
I have a quite severe problem. I am trying to compile a C++ library
initially written for VC++ 6. To make the library available for .NET
languages I want to compile the library as managed C++ library. As the
library is utilizing DirectX 9 it bases on COM. This causes me quite
some troubles as I get compile errors caused by the include files
included through the DirectX 9 header file.
The errors occur in unknwn.h, objbase.h and ObjIdl.h.

The first thing to check is the order of the include directories. Make sure
that the DX9 directory appears first, followed by a current PSDK, followed
by the VC++ directories. Usually that's all it takes when errors are
showing up in COM platform headers.

-cd
 
M

Michael Braitmaier

I did as you said. Ordered the include directories according to your answer,
but still I have the same problems.
Possibly I might miss some compiler option to set? Initially I just took the
C++ library created a .NET project, compiled it in standard C++ first which
worked and then activated the /CLR switch to enable managed C++.
I deactivated library internally used code parts by using "#pragma
unmanaged".
Do I have to activate something else considering COM compatibility under
managed C++?

Thanks so far.
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top