Linker Tools Error LNK2033

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Linker Tools Error LNK2033.

unresolved typeref token (token) for 'type'

A type doesn’t have a definition in MSIL metadata.

LNK2033 can occur when compiling with /clr:safe and where there is only a forward declaration for a type in an MSIL module, where the type is referenced in the MSIL module.

The type needs to be defined under /clr:safe.

For more information, see /clr (Common Language Runtime Compilation).

The following sample generates LNK2033.

// LNK2033.cpp  
// compile with: /clr:safe  
// LNK2033 expected  
ref class A;  
ref class B {};  
  
int main() {  
   A ^ aa = nullptr;  
   B ^ bb = nullptr;   // OK  
};  

Show: