所以我在使用我的ASP.NET核心应用程序时遇到了一些奇怪的问题,每当我加载任何Razor页面,或者做任何与Razor代码相关的事情时,我都会收到一个ArgumentOutOfRangeException。
ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: version
Microsoft.CodeAnalysis.CSharp.CSharpParseOptions.WithLanguageVersion(LanguageVersion version)
尽管谷歌搜索量很大,但我还是找不到与我所遇到的问题有关的任何内容。没有任何移动文件,重新安装或恢复nuget包有帮助。
我也尝试过重新定位不同的C#和.NET Framework版本,但无济于事。
这是基本的堆栈跟踪,我并不认为它有多大用处,但是嘿。
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 ---
答案 0 :(得分:2)
将Microsoft.CodeAnalysis.CSharp
更新为最新版本。