我怎样才能修复错误LNK 2022?

时间:2017-04-13 06:59:23

标签: c++ c++-cli

我在C ++ / CLI上创建了一个简单的库,仅用于测试:

#pragma once
using namespace System;       
namespace ClassLibrary2 {
    public ref class Class1
    {
       public:int ReturnInt()
       {
        return 40;
       }
    };
}

当我将它添加为我的C#应用​​程序的引用时,它运行良好。但是当我在#include <Windows.h>字符串之后添加代码#pragma once字符串时,错误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

我该如何解决?

1 个答案:

答案 0 :(得分:0)

我抛出PazO的答案 question:

所以在最后我刚刚安装了visual studio 2008并在#include <Windows.h>字符串之后添加了#pragma once字符串,现在它对我来说非常合适!