Crash when closing 64 bit Excel

Dec 11, 2013 at 12:20 AM
We have an Excel ribbon add-in which is using the .NET 4.0 version of FirstFloor.ModernUI. When 64 bit Excel 2010/2013 closes and a FirstFloor.ModernUI window has been shown, a crash dialog appears. Hitting the following code is sufficient to trigger the crash:
    public void buttonTest_Click(IRibbonControl control)
        ModernWindow foo = new ModernWindow();

        // Crash happens later, when Excel is closing
The crash itself is of the form:
Unhandled exception at 0x000007FEFD81940D (KernelBase.dll) in EXCEL.EXE: 0xC000041D: An unhandled exception was encountered during a user callback.
with a call stack of:
KernelBase.dll!000007fefd81940d()   Unknown
clr.dll!000007fef3b1565b()  Unknown
clr.dll!000007fef3caa666()  Unknown
clr.dll!000007fef3b37ea7()  Unknown
clr.dll!000007fef396842d()  Unknown
user32.dll!0000000077469bd1()   Unknown
user32.dll!00000000774672cb()   Unknown
user32.dll!0000000077466829()   Unknown
ntdll.dll!00000000776c11f5()    Unknown
user32.dll!000000007746193a()   Unknown
MSO.DLL!000007fee35ee20a()  Unknown
EXCEL.EXE!000000013fcbf683()    Unknown
I have not yet checked to see if the same crash happens with the .NET 4.5 version, but will follow up once I do.

This smells like a callback was registered somewhere but never unregistered. Has anyone seen this before or figured out a workaround?

Thanks, Eric
Dec 11, 2013 at 6:56 PM
Edited Dec 11, 2013 at 7:07 PM
I've confirmed that crash appears to only happens the .NET 4.0 version of the MUI library. The .NET 4.5 version doesn't seem to cause this, at least in my quick test.

I'll try to debug the source code a bit more locally. If I can't find the actual bug, the workaround may be to require .NET 4.5 for 64 bit installs, and not support 64 bit Windows XP (yes, there apparently is such a thing).