Stein Bjorhovde
asked on
How do I fix LNK2022 error when building a C++ unmanaged application in VS2008 using /clr option to enable mixed mode
I have a unmanaged C++ application that builds just fine in Visual Studio 2003. I migrated this application to VS 2008 and have set the /clr option to enable mixed mode (managed and unmanaged) for future development. After getting rid of several error messages, I am now left with one: error
stdafx.obj : LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (CCommDlgWrapper): (0x02000356)
which I just cannot figure out. I've searched the net and from what I understand it is most likely due to some badly designed structs and that the file mentioned in the error (stdafx.obj?) should be opened in Ildasm to figure out the duplicate struct information. However, opening this file in Ildasm returnes no information.
Any help would be greatly appreciated
stdafx.obj : LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (CCommDlgWrapper): (0x02000356)
which I just cannot figure out. I've searched the net and from what I understand it is most likely due to some badly designed structs and that the file mentioned in the error (stdafx.obj?) should be opened in Ildasm to figure out the duplicate struct information. However, opening this file in Ildasm returnes no information.
Any help would be greatly appreciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, the solution was in the #include stuff. I had some warnings during compilation regarding #include "ado.h" and #include "adox.h" being skipped in predefined headers - these were not in the StdAfx.h file. So I just took a chance and put these two #include in the StdAfx.h file and that did it.
Are you using any #imports? That ...Wrapper thing sounds familiar but it's been way too long since I did any MFC/ATL programming and I can't remember...
I'll have to make a note of that one for future reference as well. I wish I could find a good explanation of what is different in te newer compilers (2005 and 2008 have this issue when converting 2003 apps) that causes this problem as it is a pain in the neck to track down.
I'm glad you were able to figure it out without too much pain.
I'm glad you were able to figure it out without too much pain.
I was getting this error because of multiple defined Dllmain functions, especially if you are also using MFC and managed code. Removing these solved the problem
ASKER