I had a look over it and here's what I found:
1) The first exception, ArgumentException is occurring because you are calling GetDisplay(SIGDN_FILESYSPATH) on a IShellItem that doesn't support it. If you have a look at the docs on this, you can only call this on IShellItem that supports SIGDN_FILESYSPATH (ie which you can get via IShellItem.GetAttributes) 2) The second exception, COMException with HRESULT of E_FAIL when calling IFileDialog.GetCurrentSelection, I'm guessing is thrown when there is no current selection. The docs aren't very clear on this - so I'm not sure. The reason this only occurs under the debugger is because the exception is bubbling back into COM and getting converted into a HRESULT. Someone on the other side (ie the implementer of IFileDialog) is ignoring the HRESULT and going on their merry way. I hate when this happens, because it makes it very hard to find bugs like the above in your code. If instead, they failed hard - or returned a HRESULT when you attempted to show the dialog, then you would have found this back when using Visual Studio 2008. I'm not sure why you didn't hit this in Visual Studio 2008, however, perhaps we're now treating a transition from an exception -> HRESULT as an unhandled exception in Visual Studio 2010, and hence the debugger breaks. From: [email protected] [mailto:[email protected]] On Behalf Of Jason Keats Sent: Tuesday, April 26, 2011 9:06 PM To: ozDotNet Subject: Re: COM problems in Visual Studio 2010 I tried running compiled versions and in the IDE and stepping through the code - because I couldn't make much sense of your message. As I said, I encountered no problems/errors/exceptions - so didn't bother responding, then. There are known "issues" when debugging under a 64 bit O/S, but I don't know if that would cause your problem... http://blog.paulbetts.org/index.php/2010/07/20/the-case-of-the-disappearing-onload-exception-user-mode-callback-exceptions-in-x64/ On Wed, Apr 27, 2011 at 1:35 PM, Scott Baldwin <[email protected]<mailto:[email protected]>> wrote: Jason, the problem is that when running in Visual Studio 2010 in debug mode, it throws COM Exceptions, whereas it did no such thing in Visual Studio 2008. Perhaps the issue only occurs on Windows 7, or perhaps you have break on exceptions turned off. Ian, I have tried it in a 32bit environment, and the same problem occurs, so it's not likely a x64 problem. On Wed, Apr 27, 2011 at 12:55 PM, Ian Thomas <[email protected]<mailto:[email protected]>> wrote: I also tried the code sometime last week, on Win7 64-bit, and (in debug) got the System.Runtime.InteropServices.COMException There are a number of similar reports of this COM exception on the web. When poking through the code, I saw exception messages that were something to do with wrong # of parameters - but I haven't seen nor found an explanation. There is a suggestion that it is a 64-bit Windows problem only. As you say, the test app still works (I have not tried it in XP Mode or on a real XP, but I assume that it does there too). ________________________________ Ian Thomas Victoria Park, Western Australia ________________________________ From: [email protected]<mailto:[email protected]> [mailto:[email protected]<mailto:[email protected]>] On Behalf Of Jason Keats Sent: Wednesday, April 27, 2011 10:06 AM To: ozDotNet Subject: Re: COM problems in Visual Studio 2010 I tried your code (a week ago) on VS2010, but couldn't get it to fail when running as Administrator on Windows XP 32. What was I doing wrong? :-) On Wed, Apr 20, 2011 at 4:48 PM, Scott Baldwin <[email protected]<mailto:[email protected]>> wrote: Does anyone know if COM Interop has changed in any way in VS2010? I am getting COM exceptions when debugging an existing application in VS2010 when working with IShellItem. These COM exceptions did not occur in VS2008, and I can't find any difference in the code. The exceptions don't actually change the way in which the application works, and don't come up when not in debug mode, but I would like to get to the bottom of why they are occuring. Attached is a minimal VS2010 solution that exhibits the behaviour, any help would be much appreciated. Thanks. -- Scott Baldwin Senior Developer - QSR International<http://www.qsrinternational.com> blog: http://sjbdeveloper.blogspot.com -- Scott Baldwin Senior Developer - QSR International<http://www.qsrinternational.com> blog: http://sjbdeveloper.blogspot.com
