0

I have a simple library that I made on C++/CLI just for testing:

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

It works good, when i'm adding it as a reference to my C# application. But when i'm adding in a code #include <Windows.h> string after the #pragma once string, error LNK 2022 became:

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

How can I fix it ?

David Yaw
  • 27,383
  • 4
  • 60
  • 93
nie_trzeba
  • 41
  • 5

1 Answers1

0

I throw from the answer of PazO of this question:

So in final i just installed visual studio 2008 and add #include <Windows.h> string after the #pragma once string and now it's perfectly work for me!

Community
  • 1
  • 1
nie_trzeba
  • 41
  • 5