Unhandled exception in call to Workspace.TryApplyChanges
See original GitHub issueThe method TryApplyChanges
on Workspace
can throw a NotSupportedException
. This can for example occur due to the issue described here.
The method call in question from this solution: https://github.com/dotnet/format/blob/01ea81e043c2b4b24fb67fc8c73a95d1e4d3fb6b/src/CodeFormatter.cs#L101
The NotSupportedException
should be handled here. Right now, the format action simply crashes without much information to go on (even with verbose logging enabled):
C:\Git\DotNetFormatTest>dotnet format
Unhandled exception: System.NotSupportedException: Changing document properties is not supported
at Microsoft.CodeAnalysis.Workspace.CheckAllowedProjectChanges(ProjectChanges projectChanges)
at Microsoft.CodeAnalysis.Workspace.CheckAllowedSolutionChanges(SolutionChanges solutionChanges)
at Microsoft.CodeAnalysis.Workspace.TryApplyChanges(Solution newSolution, IProgressTracker progressTracker)
at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.TryApplyChanges(Solution newSolution, IProgressTracker progressTracker)
at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.TryApplyChanges(Solution newSolution)
at Microsoft.CodeAnalysis.Tools.CodeFormatter.FormatWorkspaceAsync(FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken, String binaryLogPath)
at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.FormatAsync(FormatOptions formatOptions, ILogger`1 logger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(InvocationContext context)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass27_0.<<UseVersionOption>b__1>d.MoveNext()--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__24_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseDebugDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseExceptionHandler>b__0>d.MoveNext()
Issue Analytics
- State:
- Created a year ago
- Reactions:10
- Comments:8
Top Results From Across the Web
Workspace.TryApplyChanges(Solution) Method
Apply changes made to a solution back to the workspace. The specified solution must be one that originated from this workspace.
Read more >c# - How do I resolve a NullReferenceException in ...
The "System.NullReferenceException: Object reference not set to an instance of the object" problem may be caused by the following:.
Read more >Error HRESULT E_FAIL has been returned from a call to a ...
COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a ... TryApplyChanges(Solution newSolution) at Microsoft.
Read more >Invalid web service call, missing value for parameter
When i open my items and go to approval page to Approve/Deny any service Requests. Am getting the above error. any advise will...
Read more >Android EMM Registration unhandled exception
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Still happens on sdk 7.0.203. This
is enough to crash
dotnet format
. No need to also enable dotnet_style_namespace_match_folder. Sorry to troll, but it’s been a year since the OP so I decided to remind of this probably forgotten issue.This happens on version
7.0.102
for me.dotnet format --version
7.0.357101+49c2ef651359526841d13e66129b71d1bcd9cef9
dotnet --version
7.0.102
dotnet --info
Exception: