views:

243

answers:

2

Hello,

I'm trying to get my project to compile with the common language runtime, and I'm suddenly running into the following linking errors, when I attempt to make a debug build:

==============================================================================

Main.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (IDirect3DVertexShader9): (0x0200056e).

Main.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (IDirect3DVertexDeclaration9): (0x0200056f).

Main.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (IDirect3DDevice9): (0x02000a2a).

Main.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (IDirect3DSwapChain9): (0x02000ab0).

Main.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (IDirect3DIndexBuffer9): (0x02000ace).

Main.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (IDirect3DVertexBuffer9): (0x02000b4e).

Main.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (IDirect3DTexture9): (0x02000bbd).

Main.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (IDirect3D9): (0x02000c0e).

LINK : fatal error LNK1255: link failed because of metadata errors

===============================================================================

I've tried rebuilding the whole solution, and I still see the same error. If anybody knows what could be causing this I'd like to know. The only solution I can see is to tell the debugger not to build debugging information for the duplicated types. The only problem is that I don't know how to do this (or indeed if it even is possible). If somebody does know, I'd appreciate the help.

Thanks so much in advance for all your help!

Daniel Auerbach

+1  A: 

Do you havce multiple versions of IDirect3D or whatever library that is? For example: say you have a couple of modules, a dll that you had pre-built (with a dependency on some unknown version of IDirect) and a module you built, with say the latest version of that library. That can give you such an error.

See MSDN documentaion for LNK 2022

dirkgently
A: 

I've gotten this error if you forward declare classes in C++/CLI, then read the full declaration somewhere else:

// one.h
class CMyNewClass;

// two.h
class CMyNewClass
{
//...
};

//main.cpp
#include "one.h"
#include "two.h"
//...

I think this combination is the one that causes this issue, but I don't have Visual Studio at hand right now to double check it.

R Caloca