Compiler Error CS0518

Predefined type 'type' is not defined or imported

The main cause for this problem is that the project is not importing mscorlib.dll, which defines the entire System namespace. This can be caused by one of the following:

  • The /nostdlib option from the command line compiler has been specified. The /nostdlib option prevents the import of mscorlib.dll. Use this option if you want to define or create a user-specific System namespace.

  • An incorrect mscorlib.dll is referenced.

  • A corrupt Visual Studio .NET or .NET Framework common language runtime installation exists.

  • Residual components from an earlier installation that are incompatible with the latest installation remain.

To resolve this problem, take one of the following actions:

  • Do not specify the /nostdlib option from the command line compiler.

  • Make sure that the project refers to the correct mscorlib.dll.

  • Reinstall the .NET Framework common language runtime (if the previous solutions do not solve the problem).