C# Error CS1110 – Cannot define a new extension method because the compiler required type ‘{0}’ cannot be found. Are you missing a reference to System.Core.dll?

C# Error

CS1110 – Cannot define a new extension method because the compiler required type ‘{0}’ cannot be found. Are you missing a reference to System.Core.dll?

Reason for the Error & Solution

Cannot use ‘this’ modifier on first parameter of method declaration without a reference to System.Core.dll. Add a reference to System.Core.dll or remove ‘this’ modifier from the method declaration.

Extension methods are supported on version 3.5 and later of .NET Framework. Extension methods generate metadata which marks the method with an attribute. The attribute class is in system.core.dll.

To correct this error

  1. As the message states, add a reference to System.Core.dll or remove the this modifier from the method declaration.

Example

The following example generates CS1110 if the file is not compiled with a reference to System.Core.dll:

// cs1110.cs  
// CS1110  
// Compile with: /target:library  
public static class Extensions  
{  
    public static bool Test(this bool b) { return b; }  
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...