• <small id='EcJPL'></small><noframes id='EcJPL'>

    <tfoot id='EcJPL'></tfoot>
    • <bdo id='EcJPL'></bdo><ul id='EcJPL'></ul>

      <legend id='EcJPL'><style id='EcJPL'><dir id='EcJPL'><q id='EcJPL'></q></dir></style></legend>
      1. <i id='EcJPL'><tr id='EcJPL'><dt id='EcJPL'><q id='EcJPL'><span id='EcJPL'><b id='EcJPL'><form id='EcJPL'><ins id='EcJPL'></ins><ul id='EcJPL'></ul><sub id='EcJPL'></sub></form><legend id='EcJPL'></legend><bdo id='EcJPL'><pre id='EcJPL'><center id='EcJPL'></center></pre></bdo></b><th id='EcJPL'></th></span></q></dt></tr></i><div id='EcJPL'><tfoot id='EcJPL'></tfoot><dl id='EcJPL'><fieldset id='EcJPL'></fieldset></dl></div>
      2. 使用/clr 时出现 LNK2022 错误

        LNK2022 Error When Using /clr(使用/clr 时出现 LNK2022 错误)

        <small id='iYm4p'></small><noframes id='iYm4p'>

        • <i id='iYm4p'><tr id='iYm4p'><dt id='iYm4p'><q id='iYm4p'><span id='iYm4p'><b id='iYm4p'><form id='iYm4p'><ins id='iYm4p'></ins><ul id='iYm4p'></ul><sub id='iYm4p'></sub></form><legend id='iYm4p'></legend><bdo id='iYm4p'><pre id='iYm4p'><center id='iYm4p'></center></pre></bdo></b><th id='iYm4p'></th></span></q></dt></tr></i><div id='iYm4p'><tfoot id='iYm4p'></tfoot><dl id='iYm4p'><fieldset id='iYm4p'></fieldset></dl></div>

            <bdo id='iYm4p'></bdo><ul id='iYm4p'></ul>
              <legend id='iYm4p'><style id='iYm4p'><dir id='iYm4p'><q id='iYm4p'></q></dir></style></legend><tfoot id='iYm4p'></tfoot>
                    <tbody id='iYm4p'></tbody>

                  本文介绍了使用/clr 时出现 LNK2022 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在使用 /clr 编译选项时在 VS2008 中链接 C++ 项目时遇到问题.我收到以下构建错误:

                  I'm having a problem linking a C++ project in VS2008 when using the /clr compile option. I am getting the following build errors:

                  Class1.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEA): (0x0200046f).
                  Class1.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEW): (0x02000473).
                  Class2.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEA): (0x0200046f).
                  Class2.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEW): (0x02000473).
                  Class3.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEA): (0x0200046e).
                  Class3.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEW): (0x02000472).
                  Class4.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEA): (0x0200046e).
                  Class4.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEW): (0x02000472).
                  Class5.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEA): (0x0200046e).
                  Class5.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEW): (0x02000472).
                  Class6.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEA): (0x0200046e).
                  Class6.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (_PROPSHEETPAGEW): (0x02000472).
                  LINK : fatal error LNK1255: link failed because of metadata errors
                  

                  我不知道 PROPSHEETPAGEAPROPSHEETPAGEW 指的是什么.我在网上查看了 Microsoft 对错误的描述,但不知道它的含义.http://support.microsoft.com/kb/324088

                  I have no idea what PROPSHEETPAGEA and PROPSHEETPAGEW are referring to. I checked online to see Microsoft's description of the error but am at a loss as to what it means. http://support.microsoft.com/kb/324088

                  要解决此问题,请在使用 C++ 托管扩展时添加唯一标识符,以避免将匿名结构用作全局变量.

                  To resolve this problem, add unique identifiers when you use Managed Extensions for C++ so that you avoid using anonymous structures as global variables.

                  Microsoft 已确认这是本文开头列出的 Microsoft 产品中的错误.此错误已在 Microsoft Visual C++ .NET (2003) 中得到纠正.

                  Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Microsoft Visual C++ .NET (2003).

                  任何想法将不胜感激.

                  编辑

                  在 Class1.obj 上执行 ildasm 后,我提取了两条消息:

                  After doing a ildasm on Class1.obj I extracted two messages:

                  // TypeDef #1134 (0200046f)
                  // -------------------------------------------------------
                  //  TypDefName: _PROPSHEETPAGEA  (0200046F)
                  //  Flags     : [NotPublic] [SequentialLayout] [Class] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100108)
                  //  Extends   : 0100000B [TypeRef] System.ValueType
                  //  Layout    : Packing:0, Size:56
                  //  CustomAttribute #1 (0c0012a0)
                  //  -------------------------------------------------------
                  //      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 #2 (0c0012a1)
                  //  -------------------------------------------------------
                  //      CustomAttribute Type: 0a000001
                  //      CustomAttributeName: Microsoft.VisualC.DebugInfoInPDBAttribute :: instance void .ctor()
                  //      Length: 4
                  //      Value : 01 00 00 00                                      >                <
                  //      ctor args: ()
                  // 
                  //  CustomAttribute #3 (0c0012a2)
                  //  -------------------------------------------------------
                  //      CustomAttribute Type: 0a000004
                  //      CustomAttributeName: System.Runtime.CompilerServices.NativeCppClassAttribute :: instance void .ctor()
                  //      Length: 4
                  //      Value : 01 00 00 00                                      >                <
                  //      ctor args: ()
                  
                  
                  // TypeDef #1138 (02000473)
                  // -------------------------------------------------------
                  //  TypDefName: _PROPSHEETPAGEW  (02000473)
                  //  Flags     : [NotPublic] [SequentialLayout] [Class] [Sealed] [AnsiClass] [BeforeFieldInit]  (00100108)
                  //  Extends   : 0100000B [TypeRef] System.ValueType
                  //  Layout    : Packing:0, Size:56
                  //  CustomAttribute #1 (0c0012b0)
                  //  -------------------------------------------------------
                  //      CustomAttribute Type: 0a000004
                  //      CustomAttributeName: System.Runtime.CompilerServices.NativeCppClassAttribute :: instance void .ctor()
                  //      Length: 4
                  //      Value : 01 00 00 00                                      >                <
                  //      ctor args: ()
                  // 
                  //  CustomAttribute #2 (0c0012b1)
                  //  -------------------------------------------------------
                  //      CustomAttribute Type: 0a000001
                  //      CustomAttributeName: Microsoft.VisualC.DebugInfoInPDBAttribute :: instance void .ctor()
                  //      Length: 4
                  //      Value : 01 00 00 00                                      >                <
                  //      ctor args: ()
                  // 
                  //  CustomAttribute #3 (0c0012b2)
                  //  -------------------------------------------------------
                  //      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 not sure what all this means, but it looks as if the second entry is identical to the first with the exception of the attributes being defined backwards.

                  推荐答案

                  今天我在我的一个项目中遇到了完全相同的问题.我通过重新排列头文件来解决它.问题是我已经将头文件移动到 cpp 文件的顶部,在包含 windows.h 的文件之前.因此,一旦我恢复了包含顺序,并将 windows.h 放回 cpp 文件的顶部,它就修复了所有内容.

                  I had this exact same problem today on one of my projects. I solved it by rearranging my header files. Problem was I had moved a header file to the top of the cpp file, before the file that was including windows.h. So, once I reverted the include order, and put windows.h back at the top of the cpp file, it fixed everything.

                  非常奇怪的修复,但对我有用.

                  very wierd fix, but it worked for me.

                  这篇关于使用/clr 时出现 LNK2022 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C++ stl unordered_map implementation, reference validity(C++ stl unordered_map 实现,参考有效性)
                  C++: Is it possible to use a reference as the value in a map?(C++:是否可以使用引用作为映射中的值?)
                  Where ampersand quot;amp;quot; can be put when passing argument by reference?(其中符号“amp;通过引用传递参数时可以放置吗?)
                  Why can a non-const reference parameter be bound to a temporary object?(为什么可以将非常量引用参数绑定到临时对象?)
                  What is a dangling reference?(什么是悬空引用?)
                  C++ reference changes when push_back new element to std::vector(当 push_back 新元素到 std::vector 时,C++ 引用发生变化)

                  <i id='HcHT1'><tr id='HcHT1'><dt id='HcHT1'><q id='HcHT1'><span id='HcHT1'><b id='HcHT1'><form id='HcHT1'><ins id='HcHT1'></ins><ul id='HcHT1'></ul><sub id='HcHT1'></sub></form><legend id='HcHT1'></legend><bdo id='HcHT1'><pre id='HcHT1'><center id='HcHT1'></center></pre></bdo></b><th id='HcHT1'></th></span></q></dt></tr></i><div id='HcHT1'><tfoot id='HcHT1'></tfoot><dl id='HcHT1'><fieldset id='HcHT1'></fieldset></dl></div>

                    <tbody id='HcHT1'></tbody>
                      1. <small id='HcHT1'></small><noframes id='HcHT1'>

                          <bdo id='HcHT1'></bdo><ul id='HcHT1'></ul>
                          <tfoot id='HcHT1'></tfoot><legend id='HcHT1'><style id='HcHT1'><dir id='HcHT1'><q id='HcHT1'></q></dir></style></legend>