WPF Control embedded in Winform causes Outlook Crash in VSTO Outlook AddIn
-
Thursday, July 15, 2010 7:06 AM
I am working on an outlook 2003 addin where we are using WPF user control embedded in a Windows form using ElementHost.
This app crashes on only few machines intermittently. After analyzing crash dump,the WPF rendering thread seems to be causing this crash.The stack trace in the windbg looks like
p movs dword ptr es:[edi],dword ptr [esi] EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff) ExceptionAddress: 7814500a (msvcr80!memcpy+0x0000005a) ExceptionCode: c0000005 (Access violation) ExceptionFlags: 00000000 NumberParameters: 2 Parameter[0]: 00000001 Parameter[1]: ab386000 Attempt to write to address ab386000 FAULTING_THREAD: 00001024 PRIMARY_PROBLEM_CLASS: STRING_DEREFERENCE BUGCHECK_STR: APPLICATION_FAULT_STRING_DEREFERENCE_INVALID_POINTER_WRITE LAST_CONTROL_TRANSFER: from 5404fa9b to 7814500a STACK_TEXT: 2206f834 5404fa9b ab386000 261b80c0 00000080 msvcr80!memcpy+0x5a 2206f8c8 540503ee 0102e810 00000006 00000002 wpfgfx_v0300!CD3DDeviceLevel1::DrawPrimitiveUP+0x313 2206f8cc 0102e810 00000006 00000002 261b80c0 wpfgfx_v0300!CD3DDeviceLevel1::FlushBufferFan+0x1f WARNING: Frame IP not in any known module. Following frames may be wrong. 2206f914 5408788b 00000000 261b80c0 00000000 0x102e810 2206f990 540878ef 2602e810 00000016 2602eb90 wpfgfx_v0300!CD3DDeviceLevel1::TestRenderTargetFormat+0x21e 2206f9b0 54087bd0 00000016 2602eb90 2206fbb4 wpfgfx_v0300!CD3DDeviceLevel1::CheckRenderTargetFormat+0x5b 2206fad4 54086c70 541870d0 26047da8 00000000 wpfgfx_v0300!CD3DDeviceManager::CreateNewDevice+0x2c3 2206fbe0 5401f473 541870d0 26047da8 000804e2 wpfgfx_v0300!CD3DDeviceManager::GetD3DDeviceAndPresentParams+0x1c1 2206fc58 5401efd6 26047da8 000804e2 00000000 wpfgfx_v0300!CHwDisplayRenderTarget::Create+0x39 2206fd98 5401f1b6 26047da8 000804e2 00000000 wpfgfx_v0300!CDesktopRenderTarget::Init+0x210 2206fdbc 5401f290 26047da8 000804e2 00000000 wpfgfx_v0300!CDesktopRenderTarget::Create+0xfa 2206fdf8 5401f339 0020cc18 26047da8 000804e2 wpfgfx_v0300!CMILFactory::CreateDesktopRenderTarget+0xc5 2206fe30 5400becc 00000000 0b8c2858 00000000 wpfgfx_v0300!CSlaveHWndRenderTarget::EnsureRenderTargetInternal+0xef 2206febc 5400be78 2206fedb 0b8b62a4 2206ff6b wpfgfx_v0300!CSlaveHWndRenderTarget::Render+0x17 2206fedc 54007523 2206ff6b 0b8b6280 00000000 wpfgfx_v0300!CRenderTargetManager::Render+0x2e 2206fef4 540075d6 2206ff6b 0b8c2730 0b8b6288 wpfgfx_v0300!CComposition::Render+0x21 2206ff58 54007667 2206ff6b 0b8b6288 008b6288 wpfgfx_v0300!CComposition::ProcessComposition+0xf3 2206ff6c 540076a2 2206ff87 00000001 0b8c2730 wpfgfx_v0300!CComposition::Compose+0x3e 2206ff88 5400717b 0b8c2730 0b8c26d0 0b8b6288 wpfgfx_v0300!CPartitionThread::RenderPartition+0x1c 2206ff9c 5400b68e 79e820a6 0000000d 0b8c2730 wpfgfx_v0300!CPartitionThread::Run+0x48 2206ffb4 7c80b729 0b8c2730 79e820a6 0000000d wpfgfx_v0300!CPartitionThread::ThreadMain+0x1e 2206ffec 00000000 5400b670 0b8c2730 00000000 kernel32!BaseThreadStart+0x37
All Replies
-
Thursday, July 15, 2010 6:30 PMModerator
Hello Deepak,
Yes, this is an access violation on WPF's render thread. Looking at this, we've seen similar crashes that were mainly due to a problem with the video driver. If you are seeing this only on a few machines, this is likely the case here as well.
The main suggestion I would have for you would be to check the video card in the affected machine(s), and see if there is a later video driver available for it, or if not, see if you can try a different video card in the affected machine(s).
Another possibility to resolve this would be to disable hardware rendering. The code path in the call stack above indicates we are using hardware rendering, so it's likely that disabling that would work around the issue. In WPF 3.x, the options for doing this are on a per-machine or per-window basis. To do it for the entire machine (as a test, not long term solution), see the "Disable Hardware Acceleration Option" section in the following MSDN link.
http://msdn.microsoft.com/en-us/library/aa970912(VS.90).aspx
To do this programmatically on a per-window basis, you can set the RenderMode of the window's HwndTarget to RenderMode.SoftwareOnly. http://msdn.microsoft.com/en-us/library/system.windows.interop.hwndtarget.rendermode.aspx
You could have code like this that ran from your Window's Loaded event.
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
HwndTarget hwndTarget = hwndSource.CompositionTarget;
// force software rendering for this window
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
Hope this helps,Keith Fink
Microsoft Communities Support- Proposed As Answer by Keith Fi - MSFTModerator Thursday, July 15, 2010 6:30 PM
- Marked As Answer by Keith Fi - MSFTModerator Thursday, July 22, 2010 2:03 PM
-
Thursday, July 22, 2010 7:13 AM
Hi Keith,
We tried disabling hardware rendering and it seems to have fixed the issue. Thanks for pointers.
Cheers!
Katta

