SOLVED: The type or namespace name 'record' could not be found
●
1 minute(s) to read
●
Permalink
●
suggest edit
https://www.jasongaylord.com/blog/2020/11/06/type-namespace-record-init-could-not-be-found
I was recently working with Hot Chocolate and used the new C# 9.0 record
types. At the time, I still had an older version of .NET 5.0 installed. When compiling, I was receiving the following error:
1
error CS0246: The type or namespace name 'record' could not be found (are you missing a using directive or assembly reference?)
I also notice the following exception when debugging in VS Code:
1
Predefined type 'System.Runtime.CompilerServices.IsExternalInit' is not defined or imported
This lead me to search for this error online. During an earlier build of .NET 5.0, both the record
type as well as init
setters were accidentally unavailable as the IsExternalInit
class was set as static
instead of sealed
. This is explained in issue 37763. Luckily, by removing the old .NET 5.0 SDK and installing the new version solved this issue.