Visual C++ Developer Center > Visual C++ Forums > Visual C++ General > error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (tagTVINSERTSTRUCTA)
Ask a questionAsk a question
 

Answer error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (tagTVINSERTSTRUCTA)

  • Wednesday, November 04, 2009 6:38 PMdaaboots Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I'm porting a VS2005 project to VS2008, and I'm having some issues. The project is a COM ATL MFC dll that has the /clr flag turned on. Its fine in the debug config, but release gives the following error:

    1>StdAfx.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (tagTVINSERTSTRUCTA): (0x02000ca9).
    1>MyClassA.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (tagTVINSERTSTRUCTA): (0x02000cb2).
    1>MyClassB.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (tagTVINSERTSTRUCTA): (0x02000d1d).
    1>LINK : fatal error LNK1255: link failed because of metadata errors

    I have run ildasm on the obj's for my project, and I have verified that the tagTVINSERTSTRUCTA size is different in some of the obj files.

    From StdAfx.obj
    // TypeDef #3240 (02000ca9)
    // -------------------------------------------------------
    //  TypDefName: tagTVINSERTSTRUCTA  (02000CA9)
    //  Flags     : [NotPublic] [SequentialLayout] [Class] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100108)
    //  Extends   : 0100000B [TypeRef] System.ValueType
    //  Layout    : Packing:0, Size:52
    //  CustomAttribute #1 (0c003503)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000001
    //   CustomAttributeName: Microsoft.VisualC.DebugInfoInPDBAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //  CustomAttribute #2 (0c003504)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000004
    //   CustomAttributeName: System.Runtime.CompilerServices.NativeCppClassAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //  CustomAttribute #3 (0c003505)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000003
    //   CustomAttributeName: Microsoft.VisualC.MiscellaneousBitsAttribute :: instance void .ctor(int32)
    //   Length: 8
    //   Value : 01 00 41 00 00 00 00 00                          >  A             <
    //   ctor args: (65)
    //
    //

    From MyClassA.obj
    // TypeDef #3250 (02000cb3)
    // -------------------------------------------------------
    //  TypDefName: tagTVINSERTSTRUCTA  (02000CB3)
    //  Flags     : [NotPublic] [SequentialLayout] [Class] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100108)
    //  Extends   : 0100000B [TypeRef] System.ValueType
    //  Layout    : Packing:0, Size:52
    //  CustomAttribute #1 (0c00352d)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000001
    //   CustomAttributeName: Microsoft.VisualC.DebugInfoInPDBAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //  CustomAttribute #2 (0c00352e)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000003
    //   CustomAttributeName: Microsoft.VisualC.MiscellaneousBitsAttribute :: instance void .ctor(int32)
    //   Length: 8
    //   Value : 01 00 41 00 00 00 00 00                          >  A             <
    //   ctor args: (65)
    //
    //  CustomAttribute #3 (0c00352f)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000004
    //   CustomAttributeName: System.Runtime.CompilerServices.NativeCppClassAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //

    From MyClassB.obj
    // TypeDef #3358 (02000d1f)
    // -------------------------------------------------------
    //  TypDefName: tagTVINSERTSTRUCTA  (02000D1F)
    //  Flags     : [NotPublic] [SequentialLayout] [Class] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100108)
    //  Extends   : 0100000B [TypeRef] System.ValueType
    //  Layout    : Packing:0, Size:52
    //  CustomAttribute #1 (0c0036eb)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000004
    //   CustomAttributeName: System.Runtime.CompilerServices.NativeCppClassAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //  CustomAttribute #2 (0c0036ec)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000003
    //   CustomAttributeName: Microsoft.VisualC.MiscellaneousBitsAttribute :: instance void .ctor(int32)
    //   Length: 8
    //   Value : 01 00 41 00 00 00 00 00                          >  A             <
    //   ctor args: (65)
    //
    //  CustomAttribute #3 (0c0036ed)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000001
    //   CustomAttributeName: Microsoft.VisualC.DebugInfoInPDBAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //

    From OtherClass1.obj
    // TypeDef #1388 (0200056d)
    // -------------------------------------------------------
    //  TypDefName: tagTVINSERTSTRUCTA  (0200056D)
    //  Flags     : [NotPublic] [SequentialLayout] [Class] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100108)
    //  Extends   : 0100000B [TypeRef] System.ValueType
    //  Layout    : Packing:0, Size:64
    //  CustomAttribute #1 (0c0016da)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000004
    //   CustomAttributeName: System.Runtime.CompilerServices.NativeCppClassAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //  CustomAttribute #2 (0c0016db)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000001
    //   CustomAttributeName: Microsoft.VisualC.DebugInfoInPDBAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //  CustomAttribute #3 (0c0016dc)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000003
    //   CustomAttributeName: Microsoft.VisualC.MiscellaneousBitsAttribute :: instance void .ctor(int32)
    //   Length: 8
    //   Value : 01 00 41 00 00 00 00 00                          >  A             <
    //   ctor args: (65)
    //
    //

    From OtherClass2.obj
    // TypeDef #1623 (02000658)
    // -------------------------------------------------------
    //  TypDefName: tagTVINSERTSTRUCTA  (02000658)
    //  Flags     : [NotPublic] [SequentialLayout] [Class] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100108)
    //  Extends   : 0100000B [TypeRef] System.ValueType
    //  Layout    : Packing:0, Size:64
    //  CustomAttribute #1 (0c001aa6)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000004
    //   CustomAttributeName: System.Runtime.CompilerServices.NativeCppClassAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //  CustomAttribute #2 (0c001aa7)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000001
    //   CustomAttributeName: Microsoft.VisualC.DebugInfoInPDBAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //  CustomAttribute #3 (0c001aa8)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000003
    //   CustomAttributeName: Microsoft.VisualC.MiscellaneousBitsAttribute :: instance void .ctor(int32)
    //   Length: 8
    //   Value : 01 00 41 00 00 00 00 00                          >  A             <
    //   ctor args: (65)
    //
    //

    From OtherClass3.obj
    // TypeDef #1623 (02000658)
    // -------------------------------------------------------
    //  TypDefName: tagTVINSERTSTRUCTA  (02000658)
    //  Flags     : [NotPublic] [SequentialLayout] [Class] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100108)
    //  Extends   : 0100000B [TypeRef] System.ValueType
    //  Layout    : Packing:0, Size:64
    //  CustomAttribute #1 (0c001aa6)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000004
    //   CustomAttributeName: System.Runtime.CompilerServices.NativeCppClassAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //  CustomAttribute #2 (0c001aa7)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000001
    //   CustomAttributeName: Microsoft.VisualC.DebugInfoInPDBAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //  CustomAttribute #3 (0c001aa8)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000003
    //   CustomAttributeName: Microsoft.VisualC.MiscellaneousBitsAttribute :: instance void .ctor(int32)
    //   Length: 8
    //   Value : 01 00 41 00 00 00 00 00                          >  A             <
    //   ctor args: (65)
    //
    //

    From OtherClass4.obj
    // TypeDef #1368 (02000559)
    // -------------------------------------------------------
    //  TypDefName: tagTVINSERTSTRUCTA  (02000559)
    //  Flags     : [NotPublic] [SequentialLayout] [Class] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100108)
    //  Extends   : 0100000B [TypeRef] System.ValueType
    //  Layout    : Packing:0, Size:64
    //  CustomAttribute #1 (0c00168b)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000004
    //   CustomAttributeName: System.Runtime.CompilerServices.NativeCppClassAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //  CustomAttribute #2 (0c00168c)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000001
    //   CustomAttributeName: Microsoft.VisualC.DebugInfoInPDBAttribute :: instance void .ctor()
    //   Length: 4
    //   Value : 01 00 00 00                                      >                <
    //   ctor args: ()
    //
    //  CustomAttribute #3 (0c00168d)
    //  -------------------------------------------------------
    //   CustomAttribute Type: 0a000003
    //   CustomAttributeName: Microsoft.VisualC.MiscellaneousBitsAttribute :: instance void .ctor(int32)
    //   Length: 8
    //   Value : 01 00 41 00 00 00 00 00                          >  A             <
    //   ctor args: (65)
    //
    //


    I'm in over my head hear, and I'm hoping someone from the CLR team can help me out!! I've read pretty much everything I could find on the web, but I'm at a loss and don't know what to do next.

    Thanks

Answers

  • Wednesday, November 11, 2009 1:32 PMdaaboots Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Sorta... I removed an include for one of our thrid party headers and it fixed the problem. Still never got to the bottom of why the issue was occuring.

All Replies

  • Friday, November 06, 2009 8:58 AMWesley YaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    This is often caused by the duplicate declaration for the type in the managed and unmanaged code, you could check this document to see whether it helps:
    Ambiguous References

    StdAfx.h will include some header files for the unmanaged code, some types in it would be duplicate with the types in the CLR, as that document pointed out, you could include the unmanaged header files before any managed using declarations, or using fully qualified names for managed symbols.

    Sincerely,
    Wesley
    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Wednesday, November 11, 2009 3:59 AMWesley YaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello,

    How are you? Is your problem resolved? May I know whether the above suggestions helped you?

    Thanks,
    Wesley


    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Wednesday, November 11, 2009 1:32 PMdaaboots Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Sorta... I removed an include for one of our thrid party headers and it fixed the problem. Still never got to the bottom of why the issue was occuring.