FIX: Error LNK2022: Metadata Operation Failed (8013118D)

This article was previously published under Q324088
This article has been archived. It is offered "as is" and will no longer be updated.
SYMPTOMS
When you declare anonymous structures globally and then compile the structures as managed code, you may receive the following (or similar) linker error messages:
error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types ($ArrayType$0x1078d980): (0x02000002).
LINK : fatal error LNK1255: link failed because of metadata errors
CAUSE
This behavior occurs because the compiler generated incorrect metadata for these anonymous structures.
RESOLUTION
To resolve this problem, add unique identifiers when you use Managed Extensions for C++ so that you avoid using anonymous structures as global variables.
STATUS
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).
MORE INFORMATION
The following code demonstrates the problem:
//c1.cpp//Compiler option required: /clrstruct { int i; }a1[] = { {1}, {2}, {3}, {4} };void FuncA(int i) { a1[i].i = i; }//End of c1.cpp//c2.cpp<BR/>//Compiler option required: /clrstruct { int i,k; } a2[] = { {1,2}, {3,4}, {4,5}, {5,6} };void FuncA(int);void main() {      FuncA(a2[1].k);}//End of c2.cpp				
Properties

Article ID: 324088 - Last Review: 12/07/2015 11:25:07 - Revision: 2.0

Microsoft Visual C++ .NET 2002 Standard Edition

  • kbnosurvey kbarchive kberrmsg kbbug kbfix kbpending kbcompiler KB324088
Feedback