Dragged and Dropped across AppDomain boundaries.

Today’s tale of Visual Studio shenanigans begins with my supervisor coming in yesterday and pointing out a new issue in our development environment since the upgrade to VisualStudio 2010.  Seems he was getting an exception whenever he dragged the content of a data grid out of our application and into Excel 2003. The text of the exception message was:

An exception of type ‘System.Runtime.InteropServices.COMException’ occurred in System.Windows.Forms.dll and wasn’t handled before a managed/native boundary

 Additional information: Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))

I couldn’t reproduce it under my environment initially. In fact, it initially seemed pretty non-deterministic.  After some isolation testing, we’d learned the following about how to reproduce the exception:

  • It wouldn’t happen with our VS 2008-built app dropping grid data into Excel 2003.
  • It wouldn’t happen with the VS 2010 build dropping data into Excel 2008.
  • It would happen with the same app built under VS 2010, dropping data into Excel 2003.
  I’ve just spent the morning trawling the Web looking for bug reports, forum and blog posts that might shed light on what was happening. I’ve learned that all sorts of things can go wrong that trigger this exception, and many of the bug-reports lodged with Microsoft around the exception tend not to be actioned because they can’t be reproduced. I finally found something that seemed close to what we were experiencing.   The forum contributors reported success by toggling off the debugging option “Break when exceptions cross AppDomain or managed/native boundaries (Managed only)”.
Debug Setting and Options Dialog, Visual Studio 2010

Debug Setting and Options Dialog, Visual Studio 2010

Taking a look at the debugging settings between our different machines, my own setting was unticked, but my supervisor’s was.  We unticked his, and we went back to being blissfully unaware of the exception. The drag-and-drop behaviour worked just fine.  What did I just do though, but flagging this setting off?  Microsoft has this to say on the setting (didn’t really help me much).

The closest I’ve come to grappling with what we might be experiencing comes from a programmer suffering with NUnit exception handling being ignored, and triggering the VS debugger breaking on exception generation regardless of whether there’s programmer handling for the exception or not. For now, I’m only luke-warm about leaving this setting off, if someone stumbles across this posting and has a really good handle on what might be going on here (or can better describe what I’m trading off by unticking this setting), drop me a comment please?

Advertisements

2 responses to “Dragged and Dropped across AppDomain boundaries.

  1. The hand of Joel Spolsky gently taps you on the shoulder from behind, and suggests that you post something on http://programmers.stackexchange.com/. I think the first incarnation might have been a slap on the back of the head, but that would have been my hand.

    It looks like an expert question which would be well placed on that site.

    Like

  2. Do I get partial points for considering something similar out of LinkedIn’s .NET community? *and watch what you do with violent acts around me, you know my pleasure and pain circuits are laid out dangerously close to each other* 🙂

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s