We have this exact issue. We traced into the .NET runtime and eventually guessed that it had to do with Printing based on the call stack. We noticed the user had a bad printer driver. When we changed the default printer to Microsoft PDF (for example) the crash went away. Sounds like a Microsoft bug me to me. At least there may be a workaround. We haven't tried this on any other systems since we just discovered this 10 minutes ago :).
"System.InvalidOperationException: Cannot perform this operation while dispatcher processing is suspended." crashes after Windows Update
Hello,
Our company developed a WPF application based on .NET 4.0 for a customer and it was released back in 2015. The application has been running without any problems. However, we are now receiving more and more crash reports where the application crashes with the above exception on startup.
Here is the stack trace:
System.Windows.Markup.XamlParseException: The invocation of the constructor on type 'App.ViewModel.Shell.ShellViewModelLocator' that matches the specified binding constraints threw an exception.
PresentationFramework
System.Object Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
at System.Windows.Application.DoStartup()
at System.Windows.Application.<.ctor>b__1_0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
Inner Exception:
System.InvalidOperationException: Cannot perform this operation while dispatcher processing is suspended.
WindowsBase
Void PushFrame(System.Windows.Threading.DispatcherFrame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.DispatcherOperation.Wait(TimeSpan timeout)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherOperation operation, CancellationToken cancellationToken, TimeSpan timeout)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at App.ViewModel.Device.DeviceViewModel.ForceCommandInvalidation() in C:\Users\...\App\ViewModel\Device\DeviceViewModel.vb:line 550
at App.ViewModel.Device.DeviceViewModel.set_CanConnectInternal(Boolean value) in C:\Users\...\App\ViewModel\Device\DeviceViewModel.vb:line 88
at App.ViewModel.Device.DeviceViewModel.RefreshCanConnectAndConnectCommand() in C:\Users\...\App\ViewModel\Device\DeviceViewModel.vb:line 337
at App.ViewModel.Device.DeviceViewModel..ctor(MultimeterDeviceBase device) in C:\Users\...\App\ViewModel\Device\DeviceViewModel.vb:line 199
at App.ViewModel.InstanceInitializer.AddRunTimeDevice() in C:\Users\...\App\ViewModel\InstanceInitializer.vb:line 71
at App.ViewModel.InstanceInitializer.InitInstances() in C:\Users\...\App\ViewModel\InstanceInitializer.vb:line 35
at App.ViewModel.GenericViewModelLocator`1.CreateMissingInstance() in C:\Users\...\App\ViewModel\GenericViewModelLocator.vb:line 27
at App.ViewModel.GenericViewModelLocator`1..ctor() in C:\Users\...\App\ViewModel\GenericViewModelLocator.vb:line 16
at App.ViewModel.Shell.ShellViewModelLocator..ctor()
Over the years, we have continued to develop the software and release newer versions. Also, in one of the last versions we raised the .NET Framework. These new versions do not have this problem and run without any problems.
After some trial and error, I was able to pinpoint the cause to a specific Windows 10/11 update:
- KB5015730 (https://support.microsoft.com/en-us/topic/august-9-2022-kb5015730-cumulative-update-preview-for-net-framework-3-5-and-4-8-for-windows-10-version-20h2-windows-server-version-20h2-windows-10-version-21h1-and-windows-10-version-21h2-f5ad5aaf-5344-439c-af2b-38a2adc05738)
- KB5015732 (https://support.microsoft.com/en-us/topic/august-9-2022-kb5015732-cumulative-update-preview-for-net-framework-3-5-and-4-8-for-windows-11-d12814d7-ca5e-493e-8afe-39ec9ba72921)
When I uninstall this update, the old version of our application works fine again.
The dilemma we have now, however, is this:
The customers who have this old version cannot upgrade to a newer version because each version is hard-coupled to a specific gauge. Theoretically, each customer would have to send the gauge back to our hardware manufacturer to have new firmware flashed onto it to make it work with our new version, but this is not so easy given the number of gauges already in the field.
Here are my questions:
- Has anyone else seen this behavior?
- Is there a workaround to get the software working again without tweaking it or permanently suppressing Windows Update itself?
I am very grateful for any answers.
Many greetings
Dave Sch.
3 answers
Sort by: Most helpful
-
-
Limitless Technology 44,506 Reputation points
2023-02-17T11:59:27.0066667+00:00 Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query
When this error occurs after a Windows Update, it is likely due to the fact that the update has changed or removed some of the Windows files necessary for the application to run properly. To resolve this issue, you can try restoring the affected files from the Windows backup folder. You can also try running a System File Checker scan and repairing the affected files. Additionally, you may need to reinstall the application or the Windows Update to get things back to normal.
If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.
-
Simon Weaver 0 Reputation points
2023-06-17T00:37:51.06+00:00 @David Schmiech Did you ever make any headway on understanding the issue?
I've had the same issue this week (multiple machines started to give this error but I could not duplicate it myself). Fortunately there were no guages involved with what we do.
Today I managed to connect to an old 4GB machine in our warehouse, install Visual Studio and keep trying things until I could make the error stop.
Eventually I came across the 'Prefer 32 bit' option under Release configuration. This was already enabled for Debug configuration. (This is old software so I have no clue what would be the default if creating a new application.)
Amazingly this fixed it and in turn made the software a lot faster.
I still have no idea what is actually happening, but it possibly might be a clue of some sort. I use some third party WPF controls and Microsoft Mshtml but it's been running for many years without issues and only minor updates.
Of course your situation is unique and hopefully resolved by now!
My Stackoverflow question: https://stackoverflow.com/questions/76494211/wpf-dispatcher-processing-suspended-error-without-useful-stack-trace/76494212#76494212