[dotnet-sdk-7.0.100-preview.2.22114.1] DbTool get exception after launch and app crashs
See original GitHub issueApplication Name: DbTool OS: Windows 10 RS5 CPU: X64 .NET Build Number: dotnet-sdk-7.0.100-preview.2.22114.1
Verify Scenarios: 1). Windows10 RS5 x64+dotnet-sdk-7.0.100-preview.2.22114.1: Fail 2). Windows10 RS5 x64+dotnet-sdk-7.0.100-preview.1.22110.4: Pass 3). Windows10 RS5 x64+dotnet-sdk-5.0.405-win-x64 (Default SDK): Pass
Github link for source code: https://github.com/WeihanLi/DbTool
App Source and App Check at : https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1483884
Findings: When we create FolderBrowserDialog object, this issue only repro if we init Description property.
Description = “this is test”, //if you remove this line, issue not repro
Minimal Repro steps: dotnet-sdk-7.0.100-preview.2.22114.1 sdk should be installed on the machine. Sample code attached. WinFormsApp1 (1).zip
- Create .net7 Winform app
- Add FolderBrowserDialog and Button Component to form
- In Button click event, write this :
private void button1_Click(object sender, EventArgs e)
{
var dialog = new System.Windows.Forms.FolderBrowserDialog
{
Description = "this is test", //if you remove this line, issue not repro
ShowNewFolderButton = true
};
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) //error here
{
}
}
Expected Result: Dialog will be closed.
Actual Result: Get below exception:
System.InvalidCastException
HResult=0x80004002
Message=Unable to cast object of type 'FileOpenDialogWrapper' to type 'IFileDialogCustomize'.
Source=System.Private.CoreLib
StackTrace:
at System.Runtime.CompilerServices.CastHelpers.ChkCast_Helper(Void* toTypeHnd, Object obj)
at System.Windows.Forms.FolderBrowserDialog.SetDialogProperties(IFileDialog dialog)
at System.Windows.Forms.FolderBrowserDialog.TryRunDialogVista(IntPtr owner, Boolean& returnValue)
at System.Windows.Forms.FolderBrowserDialog.RunDialog(IntPtr hWndOwner)
at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
at WinFormsApp1.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\v-altunc\source\repos\WpfApp2\WinFormsApp1\Form1.cs:line 17
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
at Interop.User32.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.Interop.Mso.IMsoComponentManager.FPushMessageLoop(UIntPtr dwComponentID, msoloop uReason, Void* pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(msoloop reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(msoloop reason, ApplicationContext context)
at WinFormsApp1.Program.Main() in C:\Users\v-altunc\source\repos\WpfApp2\WinFormsApp1\Program.cs:line 14
This exception was originally thrown at this call stack:
System.Windows.Forms.FolderBrowserDialog.SetDialogProperties(Interop.Shell32.IFileDialog)
System.Windows.Forms.FolderBrowserDialog.TryRunDialogVista(System.IntPtr, out bool)
System.Windows.Forms.FolderBrowserDialog.RunDialog(System.IntPtr)
System.Windows.Forms.CommonDialog.ShowDialog(System.Windows.Forms.IWin32Window)
WinFormsApp1.Form1.button1_Click(object, System.EventArgs) in Form1.cs
System.Windows.Forms.Button.OnMouseUp(System.Windows.Forms.MouseEventArgs)
System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message, System.Windows.Forms.MouseButtons, int)
System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message)
System.Windows.Forms.ButtonBase.WndProc(ref System.Windows.Forms.Message)
System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message)
...
[Call Stack Truncated]
Repro steps for affected app: This is .Net 5.0 app, but we are running it on 7.0, machine only have 7.0 installed, and DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2, so it runs on 7.0 1.Launch DbTool.exe. 3.Input connection string: Server=(localdb)\MSSQLLocalDB;Database=master. 4.Select “SqlServer” item. 5.Click Connect button. 6.Check the item MSreplicationoptions. 7.Click “导出C# Code” button.
Expected Result: Export successful.
Actual Result: It shows error and crash.
Application: DbTool.exe
CoreCLR Version: 7.0.22.10302
.NET Version: 7.0.0-preview.2.22103.2
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidCastException: Unable to cast object of type 'FileOpenDialogWrapper' to type 'IFileDialogCustomize'.
at System.Windows.Forms.FolderBrowserDialog.SetDialogProperties(IFileDialog dialog)
at System.Windows.Forms.FolderBrowserDialog.TryRunDialogVista(IntPtr owner, Boolean& returnValue)
at System.Windows.Forms.FolderBrowserDialog.RunDialog(IntPtr hWndOwner)
at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
at DbTool.MainWindow.ChooseFolder() in C:\sourcr\DbTool\src\DbTool\MainWindow.xaml.cs:line 395
at DbTool.MainWindow.ExportModel_Click(Object sender, RoutedEventArgs e) in C:\sourcr\DbTool\src\DbTool\MainWindow.xaml.cs:line 145
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at DbTool.App.Main() in C:\sourcr\DbTool\src\DbTool\obj\Debug\net5.0-windows\App.g.cs:line 51
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
Verified with 7.0.100-preview.3.22118.7, this issue has been fixed. Thanks
@kant2002 not easily, many dashboards, feeds and tools are internal only. In general the flow is, dotnet/winforms > dotnet/wpf > dotnet/windowsdesktop > dotnet/sdk > dotnet/installer. So to see that a particular commit has flown, one needs to walk down the stream and check each repo’s “[main] Update dependencies from dotnet/XYZ” PRs.