   [.net] native/unmaged C++/CLI
  I recently added some new code files to a C++/CLI project.  The addedcode is all native.  I simply added the code to the project and builtit.  It compiled fine but I am getting the linker error:LNK2022: metadata operation failed (8013118D) : Inconsistent layoutinformation in duplicated types (IDirect3DDevice9): (0x0200015b)I get this in three .obj files.  Each file has a different class, buteach class holds a member to an IDirect3DDevice9 pointer.  But I'm notsure why this throws a LNK2022 error, which seems to have to do withdefining classes of the same name.   
  From the MSDN:Quote:Error Message metadata operation failed (HRESULT) : error_messageThe linker detected an error while merging metadata. The metadata errors must be resolved to link successfully.One way to diagnose this problem is to run ildasm –tokens on the object files to find which types have the tokens listed in error_message, and look for differences. In metadata, two different types with the same name is not valid, even if the just LayoutType attribute is different.One reason for LNK2022 is when a type (such as a struct) exists in multiple compilands with the same name, but with conflicting definitions, and when you compile with /clr. In this case, make sure that the type has an identical definition in all compilands. The type name is listed in error_message.Another possible cause for LNK2022 is when the linker finds a metadata file in a different location than was specified to the compiler (with #using ). Make sure that the metadata file (.dll or .netmodule) is in the same location when passed to the linker, as it was when it was passed to the compiler.Skizz   ;  You think I didn't read that already?   ;  It compiles and links if I comment out #include <d3dx9.h>//#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;...Can anyone explain this?   ;Quote:Original post by QuatIt compiles and links if I comment out #include <d3dx9.h>//#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;...Can anyone explain this?that seems to match up pretty well to this description:Quote:One reason for LNK2022 is when a type (such as a struct) exists in multiple compilands with the same name, but with conflicting definitions, and when you compile with /clr. In this case, make sure that the type has an identical definition in all compilands. The type name is listed in error_message.