This post covers all the .NET related articles covered as part of C# Tips & Tricks series and C# compiler errors in DeveloperPublish.com
List of C# Compiler Errors
- C# Error CS9050 – A ref field cannot refer to a ref struct.
- C# Error CS9043 – Ref returning properties cannot be required.
- C# Error CS8812 – Cannot convert &method group ‘{0}’ to non-function pointer type ‘{1}’.
- C# Error CS8803 – Top-level statements must precede namespace and type declarations.
- C# Error CS8515 – Parentheses are required around the switch governing expression.
- C# Error CS8411 – Asynchronous foreach statement cannot operate on variables of type ‘{0}’ because ‘{0}’ does not contain a suitable public instance or extension definition for ‘{1}’
- C# Error CS8410 – ‘{0}’: type used in an asynchronous using statement must be implicitly convertible to ‘System.IAsyncDisposable’ or implement a suitable ‘DisposeAsync’ method.
- C# Error CS8403 – Method ‘{0}’ with an iterator block must be ‘async’ to return ‘{1}’
- C# Error CS8401 – To use ‘@$’ instead of ‘$@’ for an interpolated verbatim string, please use language version ‘{0}’ or greater.
- C# Error CS8400 – Feature ‘{0}’ is not available in C# 8.0. Please use language version {1} or greater.
- C# Error CS8374 – Cannot ref-assign ‘{1}’ to ‘{0}’ because ‘{1}’ has a narrower escape scope than ‘{0}’.
- C# Error CS8373 – The left-hand side of a ref assignment must be a ref variable.
- C# Error CS8354 – Cannot return ‘this’ by reference.
- C# Error CS8334 – Members of {0} ‘{1}’ cannot be returned by writable reference because it is a readonly variable
- C# Error CS8333 – Cannot return {0} ‘{1}’ by writable reference because it is a readonly variable
- C# Error CS8210 – A tuple may not contain a value of type ‘void’.
- C# Error CS8178 – ‘await’ cannot be used in an expression containing a call to ‘{0}’ because it returns by reference
- C# Error CS8177 – Async methods cannot have by-reference locals
- C# Error CS8176 – Iterators cannot have by-reference locals
- C# Error CS8175 – Cannot use ref local ‘{0}’ inside an anonymous method, lambda expression, or query expression
- C# Error CS8174 – A declaration of a by-reference variable must have an initializer
- C# Error CS8173 – The expression must be of type ‘{0}’ because it is being assigned by reference
- C# Error CS8172 – Cannot initialize a by-reference variable with a value
- C# Error CS8171 – Cannot initialize a by-value variable with a reference
- C# Error CS8170 – Struct members cannot return ‘this’ or other instance members by reference
- C# Error CS8169 – Cannot return a member of local ‘{0}’ by reference because it is not a ref local
- C# Error CS8168 – Cannot return local ‘{0}’ by reference because it is not a ref local
- C# Error CS8167 – Cannot return by reference a member of parameter ‘{0}’ because it is not a ref or out parameter
- C# Error CS8166 – Cannot return a parameter by reference ‘{0}’ because it is not a ref parameter
- C# Error CS8163 – Fields of static readonly field ‘{0}’ cannot be returned by writable reference
- C# Error CS8162 – Members of readonly field ‘{0}’ cannot be returned by writable reference
- C# Error CS8161 – A static readonly field cannot be returned by writable reference
- C# Error CS8160 – A readonly field cannot be returned by writable reference
- C# Error CS8159 – Cannot return the range variable ‘{0}’ by reference
- C# Error CS8158 – Cannot return by reference a member of ‘{0}’ because it was initialized to a value that cannot be returned by reference
- C# Error CS8157 – Cannot return ‘{0}’ by reference because it was initialized to a value that cannot be returned by reference
- C# Error CS8156 – An expression cannot be used in this context because it may not be passed or returned by reference
- C# Error CS8155 – Lambda expressions that return by reference cannot be converted to expression trees
- C# Error CS8154 – The body of ‘{0}’ cannot be an iterator block because ‘{0}’ returns by reference
- C# Error CS8153 – An expression tree lambda may not contain a call to a method, property, or indexer that returns by reference
- C# Error CS8152 – ‘{0}’ does not implement interface member ‘{1}’. ‘{2}’ cannot implement ‘{1}’ because it does not have matching return by reference.
- C# Error CS8151 – The return expression must be of type ‘{0}’ because this method returns by reference
- C# Error CS8150 – By-value returns may only be used in methods that return by value
- C# Error CS8149 – By-reference returns may only be used in methods that return by reference
- C# Error CS8148 – ‘{0}’ must match by reference return of overridden member ‘{1}’
- C# Error CS8147 – Properties which return by reference cannot have set accessors
- C# Error CS8146 – Properties which return by reference must have a get accessor
- C# Error CS8145 – Auto-implemented properties cannot return by reference
- C# Error CS8141 – The tuple element names in the signature of method ‘{0}’ must match the tuple element names of interface method ‘{1}’ (including on the return type).
- C# Error CS8140 – ‘{0}’ is already listed in the interface list on type ‘{2}’ with different tuple element names, as ‘{1}’.
- C# Error CS8139 – ‘{0}’: cannot change tuple element names when overriding inherited member ‘{1}’
- C# Error CS8132 – Cannot deconstruct a tuple of ‘{0}’ elements into ‘{1}’ variables.
- C# Error CS8131 – Deconstruct assignment requires an expression with a type on the right-hand-side.
- C# Error CS8130 – Cannot infer the type of implicitly-typed deconstruction variable ‘{0}’.
- C# Error CS8129 – No suitable ‘Deconstruct’ instance or extension method was found for type ‘{0}’, with {1} out parameters and a void return type.
- C# Error CS8127 – Tuple element names must be unique.
- C# Error CS8125 – Tuple element name ‘{0}’ is only allowed at position {1}.
- C# Error CS8124 – Tuple must contain at least two elements.
- C# Error CS7003 – Unexpected use of an unbound generic name
- C# Error CS7000 – Unexpected use of an aliased name
- C# Error CS5001 – Program does not contain a static ‘Main’ method suitable for an entry point
- C# Error CS4033 – The ‘await’ operator can only be used within an async method. Consider marking this method with the ‘async’ modifier and changing its return type to ‘Task’.
- C# Error CS4032 – The ‘await’ operator can only be used within an async method. Consider marking this method with the ‘async’ modifier and changing its return type to ‘Task<{0}>‘.
- C# Error CS4013 – Instance of type ‘{0}’ cannot be used inside a nested function, query expression, iterator block or async method
- C# Error CS4009 – A void or int returning entry point cannot be async
- C# Error CS4008 – Cannot await ‘void’
- C# Error CS4004 – Cannot await in an unsafe context
- C# Error CS2036 – The /pdb option requires that the /debug option also be used
- C# Error CS2035 – Command-line syntax error: Missing ‘:
‘ for ‘{0}’ option - C# Error CS2034 – A /reference option that declares an extern alias can only have one filename. To specify multiple aliases or filenames, use multiple /reference options.
- C# Error CS2033 – Cannot create short filename ‘{0}’ when a long filename with the same short filename already exists
- C# Error CS2024 – Invalid file section alignment ‘{0}’
- C# Error CS2021 – File name ‘{0}’ is empty, contains invalid characters, has a drive specification without an absolute path, or is too long
- C# Error CS2019 – Invalid target type for /target: must specify ‘exe’, ‘winexe’, ‘library’, or ‘module’
- C# Error CS2017 – Cannot specify /main if building a module or library
- C# Error CS2016 – Code page ‘{0}’ is invalid or not installed
- C# Error CS2015 – ‘{0}’ is a binary file instead of a text file
- C# Error CS2013 – Invalid image base number ‘{0}’
- C# Error CS2012 – Cannot open ‘{0}’ for writing — ‘{1}’
- C# Error CS2011 – Error opening response file ‘{0}’
- C# Error CS2008 – No source files specified.
- C# Error CS2007 – Unrecognized option: ‘{0}’
- C# Error CS2006 – Command-line syntax error: Missing ‘{0}’ for ‘{1}’ option
- C# Error CS2005 – Missing file specification for ‘{0}’ option
- C# Error CS2001 – Source file ‘{0}’ could not be found.
- C# Error CS1997 – Since ‘{0}’ is an async method that returns ‘Task’, a return keyword must not be followed by an object expression. Did you intend to return ‘Task
‘? - C# Error CS1996 – Cannot await in the body of a lock statement
- C# Error CS1994 – The ‘async’ modifier can only be used in methods that have a body.
- C# Error CS1988 – Async methods cannot have ref, in or out parameters
- C# Error CS1986 – ‘await’ requires that the type {0} have a suitable ‘GetAwaiter’ method
- C# Error CS1983 – The return type of an async method must be void, Task, Task
, a task-like type, IAsyncEnumerable , or IAsyncEnumerator - C# Error CS1959 – ‘{0}’ is of type ‘{1}’. The type specified in a constant declaration must be sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, decimal, bool, string, an enum-type, or a reference-type.
- C# Error CS1958 – Object and collection initializer expressions may not be applied to a delegate creation expression
- C# Error CS1955 – Non-invocable member ‘{0}’ cannot be used like a method.
- C# Error CS1954 – The best overloaded method match ‘{0}’ for the collection initializer element cannot be used. Collection initializer ‘Add’ methods cannot have ref or out parameters.
- C# Error CS1952 – An expression tree lambda may not contain a method with variable arguments
- C# Error CS1951 – An expression tree lambda may not contain a ref, in or out parameter
- C# Error CS1950 – The best overloaded Add method ‘{0}’ for the collection initializer has some invalid arguments
- C# Error CS1949 – The contextual keyword ‘var’ cannot be used in a range variable declaration
- C# Error CS1948 – The range variable ‘{0}’ cannot have the same name as a method type parameter