Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RaceOnRCWCleanup when closing WPF apps

For the past few years, I've been using WPF in a mixed-mode app to display various bits & pieces of UI. WPF is used by a C# assembly to generate the UI - it references a C++/CLI-built assembly that contains some native code. The native code makes no OS calls beyond a few printf's; it's purely computational.

When running with a debugger attached, I see the managed debug assistent "RaceOnRCWCleanup" fire after I close the app - suggesting there's some COM component with multithreading cleanup issues.

I'm not using COM in any fashion directly, but perhaps C++/CLI or WPF is. Warnings about application shutdown aren't particularly scary - after all, the app is exiting anyway - but I'd love to understand what's going wrong. Can I do anything to avoid this warning? Is there a hidden bug somewhere that's just waiting to bite me, or is it a spurious warning?

This is an example stacktrace:

mscorlib.dll!System.Runtime.InteropServices.Marshal.ReleaseComObject(object o) Line 1826 + 0xc bytes    C#
PresentationFramework.dll!System.Windows.Documents.TextServicesHost.DeactivateThreadManager() Line 465 + 0xd bytes  C#
PresentationFramework.dll!System.Windows.Documents.TextServicesHost.OnUnregisterTextStore(object arg) Line 331  C#
PresentationFramework.dll!System.Windows.Documents.TextEditor.DetachTextStore(bool finalizer) Line 249 + 0x6b bytes C#
WindowsBase.dll!System.Windows.Threading.Dispatcher.ShutdownImplInSecurityContext(object state) Line 1363 + 0xfffffffc bytes    C#
mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) Line 484 + 0xce bytes    C#

Has anyone experienced the same issue? Does anybody know what's going on?

like image 555
Eamon Nerbonne Avatar asked Nov 02 '10 16:11

Eamon Nerbonne


1 Answers

Since when do you get this exception? I also got it today for the first time on our wpf business application. It occurs continous everytime I close the application, without having made major changes. Maybe some Windows Update is the source of evil? We also did not figure out where it comes from, nor how to prevent it, yet. I will post a solution as soon as we managed to get the exception solved. I dont think that it has something to do with your C++/CLI assembly. We dont use C++/CLI assemblies.

Jan

like image 82
JanW Avatar answered Oct 28 '22 14:10

JanW