Tôi gặp sự cố khi liên kết dự án C++ trong VS2008 khi sử dụng tùy chọn biên dịch /clr
. Tôi nhận được lỗi sau xây dựng:LNK2022 Lỗi khi sử dụng/clr
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
Tôi không có ý tưởng gì PROPSHEETPAGEA
và PROPSHEETPAGEW
đang đề cập đến. Tôi đã kiểm tra trực tuyến để xem mô tả của Microsoft về lỗi này nhưng tôi không biết nó có ý nghĩa gì. http://support.microsoft.com/kb/324088
Để giải quyết vấn đề này, thêm định danh duy nhất khi bạn sử dụng phần mở rộng cho C++ Managed để bạn tránh sử dụng các cấu trúc vô danh như biến toàn cục.
Microsoft đã xác nhận rằng đây là lỗi trong các sản phẩm của Microsoft được liệt kê ở đầu bài viết này. Lỗi này đã được sửa chữa trong Microsoft Visual C++ .NET (2003).
Bất kỳ ý tưởng nào cũng sẽ được đánh giá cao.
EDIT
Sau khi thực hiện một ildasm trên Class1.obj tôi trích ra hai thông điệp:
// 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)
Tôi không chắc chắn những gì tất cả điều này có nghĩa, nhưng có vẻ như nếu mục thứ hai là giống với đầu tiên ngoại trừ các thuộc tính được định nghĩa ngược.
Tôi đã sửa đổi thiết lập giải pháp để chứa tất cả mã được quản lý trong một dự án duy nhất thay vì nhiều dự án và lỗi đã biến mất. Nó sẽ mãi mãi là một bí ẩn ... – lumberjack4