Thomas May
Thomas May

Reputation: 13

"ArgumentOutOfRangeException" loading any razor page

So I've been having some strange issues with an ASP.NET Core app of mine, whenever I load any Razor page, or do anything in relation to Razor code, I get an ArgumentOutOfRangeException thrown at me.

ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: version
Microsoft.CodeAnalysis.CSharp.CSharpParseOptions.WithLanguageVersion(LanguageVersion version)

Despite intense Googling, I've not been able to find anything related to the issue I'm having. No amounts of moving files around, reinstalling or restoring of nuget packages has helped.

I've also tried re-targeting different C# and .NET Framework versions, to no avail.

Here's the basic stack trace, I don't really see it being of much use, but hey.

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: version
   at Microsoft.CodeAnalysis.CSharp.CSharpParseOptions.WithLanguageVersion(LanguageVersion version)
   at Microsoft.AspNetCore.Mvc.Razor.Internal.DependencyContextRazorViewEngineOptionsSetup.SetParseOptions(RazorViewEngineOptions options, CompilationOptions compilationOptions)
   at Microsoft.AspNetCore.Mvc.Razor.Internal.DependencyContextRazorViewEngineOptionsSetup.Configure(RazorViewEngineOptions options)
   at Microsoft.Extensions.Options.OptionsCache`1.CreateOptions()
   at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
   at Microsoft.Extensions.Options.OptionsCache`1.get_Value()
   at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorReferenceManager..ctor(ApplicationPartManager partManager, IOptions`1 optionsAccessor)
--- End of stack trace from previous location where exception was thrown ---

Upvotes: 1

Views: 445

Answers (1)

Cristian Szpisjak
Cristian Szpisjak

Reputation: 2469

Update the Microsoft.CodeAnalysis.CSharp to the latest version.

Upvotes: 2

Related Questions