The Issue
Hi,
I am attempting to update an ASP.NET Framework project from C# version 5 to a more modern version of the language. However, the automatic updater errors out every time I attempt to run it and I can’t find anything online on how to do it manually, nor can I find anything related to this specific issue.
Edit:
The code causing this issue is part of Visual Studio, and as such is not part of my own code, thus I don’t feel it is relevant in any way to post my code. I know full well what a NullReferenceException is, I don’t know how to fix a visual studio extension.
For goodness sake SO, please read beyond the title. The referenced question is about fixing errors in your own code, I need to update a C# version.
Please find below the stack trace that it provides:
System.NullReferenceException : Object reference not set to an instance of an object.
at Microsoft.VisualStudio.LanguageServices.Utilities.ProjectPropertyStorage.PerConfigurationPropertyStorage.SetProperty(String buildPropertyName,String configurationPropertyName,String value)
at Microsoft.CodeAnalysis.Workspace.ApplyProjectChanges(ProjectChanges projectChanges)
at Microsoft.CodeAnalysis.Workspace.TryApplyChanges(Solution newSolution,IProgressTracker progressTracker)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.TryApplyChanges(Solution newSolution,IProgressTracker progressTracker)
at Microsoft.CodeAnalysis.CodeActions.ApplyChangesOperation.ApplyOrMergeChanges(Workspace workspace,Solution originalSolution,Solution changedSolution,IProgressTracker progressTracker,CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CodeActions.ApplyChangesOperation.TryApplyAsync(Workspace workspace,Solution originalSolution,IProgressTracker progressTracker,CancellationToken cancellationToken)
at async Microsoft.CodeAnalysis.CodeActions.CodeActionEditHandlerService.ProcessOperationsAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.CodeActions.CodeActionEditHandlerService.ApplyAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.InvokeWorkerAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformActionAsync(<Unknown Parameters>)
What I tried
So far I have explored various levels of SEO-fu to get anything even remotely related, but to no avail. When I open the Property Pages window for the project I can only go up to Target Framework 4.8 as that is the newest version. According to the Microsoft Learn site, .NET Framework should default to C# 7.3, yet the version my ASP site is using is C# 5. I know this as the tooltip when I attempt to use target-typed object creation alerts me that I am using C# 5.
Any help on this matter would be appreciated.
2
Answers
Thanks to @Ralf in the comments this has been resolved. I would prefer to give them the karma but I can't mark a comment as an answer.
For reference: The workaround provided was found at this link.
The workaround was to manually adjust the language version in web.config. My version of the file appeared to be missing the block of code entirely.
The "System.NullReferenceException: Object reference not set to an instance of the object" problem may be caused by the following:
If you can eliminate the above problems, then please open Visual Studio Installer to repair Visual Studio.