I have a WinForms C # Visual Studio 2008 (.NET 3.5) solution that needs to be upgraded to Visual Studio 2010 (.NET will remain on version 3.5). This solution uses FileDialog from the Vista API for two reasons:
- When running the application on Windows XP, the expectation is to provide the user with a Windows XP-style search dialog box. When starting the same application in Windows Vista and 7, the file dialog should look like Vista.
- More importantly, our application allows the user to open a project file, which can be either a local file (stored on a user computer or a USB device) or a server project (hosted in MS SQL Server). To do this, we use the Vista API, as we can access the event handler of the file type drop-down control. Therefore, the implementation is such that the user is presented with an open file dialog box, and when they select the "Server" option in the file type drop-down list, the file open dialog is closed and another dialog box opens, allowing the user to select the server to which they want connect and server project.
In Visual Studio 2008, when debugging an application, there is no problem with the Vista API. When the solution is updated to Visual Studio 2010 (runs on Windows 7), the user tries to debug the application, and the user wants to access the Open API Vista dialog box, the application crashes with an ArgumentException with the following message: "The value is not in the expected range." Oddly enough, when a user launches a solution without debugging (Ctrl + F5) from Visual Studio 2010, there are no exceptions. Abusive code:
internal void DoFolderChange(IFileDialog dialog) { IShellItem ppsi = null; string ppszName = string.Empty; dialog.GetFolder(out ppsi);
I tried google search but to no avail. I have a sample Visual Studio 2010 solution with the Vista API, and the problem also occurs in this solution. A sample project can be downloaded (in ZIP format) from here . To reproduce the problem:
- Debug a solution in Visual Studio 2010.
- After starting "Vista Api Demo" click on the "Dialogs" tab.
- In the Vista Look column located on the right side of the Dialogs tab, click the Open File button.
- A dialog box appears with the message "The file type has been changed to 1". Click OK.
- Please note that at this moment the application crashes with an error that was excluded from the DoFolderChange (IFileDialog) method in clsFileDialog.cs.
My apologies for the long post, but I needed to explain the whole background why the implementation of the Vista API dialog box is required. I am very grateful for the help in solving this problem, since my development team is working on Visual Studio 2010, and we do not want the developers to try to combine and separate the debugger in order to get around this problem.
source share