HomeCSharpC# 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?

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

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...