I recently added some new code files to a C++/CLI project. The added
code is all native. I simply added the code to the project and built
it. It compiled fine but I am getting the linker error:
LNK2022: metadata operation failed (8013118D) : Inconsistent layout
information in duplicated types (IDirect3DDevice9): (0x0200015b)
I get this in three .obj files. Each file has a different class, but
each class holds a member to an IDirect3DDevice9 pointer. But I'm not
sure why this throws a LNK2022 error, which seems to have to do with
defining classes of the same name.
dragonslayer008@hotmail.com - 17 Sep 2007 17:57 GMT
I seem to have found the situation that may be causing these.
As said, the native classes have IDirect3DDevice9* data members. A
managed ref class also has an IDirect3DDevice9* data member. It seems
the compiler does not like this, because if I remove the
IDirect3DDevice9* data member from the managed class, the linker
errors go away. On the other hand, this worked fine before I added
the native classes. So can you not have instances of the same type in
a managed class and native class?
dragonslayer008@hotmail.com - 17 Sep 2007 18:35 GMT
Okay, I got it to work (it compiles and links) if I comment out
#include <d3dx9.h> at the top of the .h file that houses the managed
class
//#include <d3dx9.h> // works now
#include "Box.h" // Box.h #includes <d3dx9.h> too
#include <fstream>
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
... managed class definition
Can anyone explain this?
Ben Voigt [C++ MVP] - 17 Sep 2007 20:12 GMT
> Okay, I got it to work (it compiles and links) if I comment out
> #include <d3dx9.h> at the top of the .h file that houses the managed
[quoted text clipped - 14 lines]
>
> Can anyone explain this?
Apparently "Box.h" is making some #define changes that affect the windows
header files. That's why the compiler complained, because the #define
values used for IDirect3DWhatever were different in different source files.