我该如何修复错误 LNK 2022?
How can i fix error LNK 2022?
我有一个简单的库,是我在 C++/CLI 上制作的,仅用于测试:
#pragma once
using namespace System;
namespace ClassLibrary2 {
public ref class Class1
{
public:int ReturnInt()
{
return 40;
}
};
}
当我将它添加为对我的 C# 应用程序的引用时,它运行良好。但是当我在 #pragma once
字符串后添加代码 #include <Windows.h>
字符串时,错误 LNK 2022 变为:
MSVCMRT.lib(mstartup.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0001e2).
MSVCMRT.lib(mstartup.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0001e6).
MSVCMRT.lib(managdeh.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000c0).
MSVCMRT.lib(managdeh.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000c2).
MSVCMRT.lib(mehvecdtr.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000a6).
MSVCMRT.lib(mehvecdtr.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000a9).
MSVCMRT.lib(ManagedMain.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000bf).
MSVCMRT.lib(ManagedMain.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000c1).
MSVCMRT.lib(msilexit.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000e9).
MSVCMRT.lib(msilexit.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000ec).
MSVCMRT.lib(pureMSILcode.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c000199).
MSVCMRT.lib(pureMSILcode.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c00019a).
LINK : fatal error LNK1255: link failed because of metadata errors
我该如何解决?
我从PazO的回答中抛出这个
question:
所以在最后我刚刚安装了 visual studio 2008 并在 #pragma once
字符串之后添加了 #include <Windows.h>
字符串,现在它非常适合我!
我有一个简单的库,是我在 C++/CLI 上制作的,仅用于测试:
#pragma once
using namespace System;
namespace ClassLibrary2 {
public ref class Class1
{
public:int ReturnInt()
{
return 40;
}
};
}
当我将它添加为对我的 C# 应用程序的引用时,它运行良好。但是当我在 #pragma once
字符串后添加代码 #include <Windows.h>
字符串时,错误 LNK 2022 变为:
MSVCMRT.lib(mstartup.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0001e2). MSVCMRT.lib(mstartup.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0001e6). MSVCMRT.lib(managdeh.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000c0). MSVCMRT.lib(managdeh.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000c2). MSVCMRT.lib(mehvecdtr.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000a6). MSVCMRT.lib(mehvecdtr.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000a9). MSVCMRT.lib(ManagedMain.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000bf). MSVCMRT.lib(ManagedMain.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000c1). MSVCMRT.lib(msilexit.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000e9). MSVCMRT.lib(msilexit.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0000ec). MSVCMRT.lib(pureMSILcode.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c000199). MSVCMRT.lib(pureMSILcode.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c00019a). LINK : fatal error LNK1255: link failed because of metadata errors
我该如何解决?
我从PazO的回答中抛出这个 question:
所以在最后我刚刚安装了 visual studio 2008 并在 #pragma once
字符串之后添加了 #include <Windows.h>
字符串,现在它非常适合我!