首页 > 解决方案 > obj 文件中的元数据标记是什么?

问题描述

我遇到了 c++ cli 的链接器错误:

错误 LNK2022 元数据操作失败(80131195):自定义属性不一致:(0x0c00019d)。foo.obj 1

错误 LNK2022 元数据操作失败(80131195):自定义属性不一致:(0x0c0001ab)。bar.obj 1

什么是元数据令牌?我已经通过 学习了 obj 文件ildasm,但我不知道真正的问题是什么。以下是简要内容:

foo.obj:

// TypeDef #190 (020000bf)
// -------------------------------------------------------
//  TypDefName: FooClass  (020000BF)
//  Flags     : [Public] [SequentialLayout] [Class] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100109)
//  Extends   : 01000017 [TypeRef] System.ValueType
//  Layout    : Packing:0, Size:12
//  CustomAttribute #1 (0c00019c)
//  -------------------------------------------------------
//      CustomAttribute Type: 0a000006
//      CustomAttributeName: System.Runtime.CompilerServices.NativeCppClassAttribute :: instance void .ctor()
//      Length: 4
//      Value : 01 00 00 00                                      >                <
//      ctor args: ()
// 
//  CustomAttribute #2 (0c00019d)
//  -------------------------------------------------------
//      CustomAttribute Type: 0a000007
//      CustomAttributeName: System.CLSCompliantAttribute :: instance void .ctor(bool)
//      Length: 5
//      Value : 01 00 00 00 00                                   >                <
//      ctor args: ( <can not decode> )

bar.obj

// TypeDef #199 (020000c8)
// -------------------------------------------------------
//  TypDefName: FooClass  (020000C8)
//  Flags     : [Public] [SequentialLayout] [Class] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100109)
//  Extends   : 01000016 [TypeRef] System.ValueType
//  Layout    : Packing:0, Size:12
//  CustomAttribute #1 (0c0001aa)
//  -------------------------------------------------------
//      CustomAttribute Type: 0a000006
//      CustomAttributeName: System.Runtime.CompilerServices.NativeCppClassAttribute :: instance void .ctor()
//      Length: 4
//      Value : 01 00 00 00                                      >                <
//      ctor args: ()
// 
//  CustomAttribute #2 (0c0001ab)
//  -------------------------------------------------------
//      CustomAttribute Type: 0a000007
//      CustomAttributeName: System.CLSCompliantAttribute :: instance void .ctor(bool)
//      Length: 5
//      Value : 01 00 00 00 00                                   >                <
//      ctor args: ( <can not decode> )

我所看到的,FooClass 扩展了不同的 ValueTypes(我不知道为什么)。是否有关于该令牌的任何文档?是关于符号的某种 pdb 信息吗?

标签: c++-cliclr

解决方案


推荐阅读