[Bug 50042] New: Wine fails to execute .NET C# "ShowDialog()"
https://bugs.winehq.org/show_bug.cgi?id=50042 Bug ID: 50042 Summary: Wine fails to execute .NET C# "ShowDialog()" Product: Wine Version: unspecified Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs(a)winehq.org Reporter: forinih564(a)nic58.com Distribution: --- Created attachment 68490 --> https://bugs.winehq.org/attachment.cgi?id=68490 The program trying to run the C# lines SaveFileDialog savefiledialg = new SaveFileDialog(); savefiledialg.ShowDialog(); or OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.ShowDialog() causes the application to crash the source code for the attached program is private void button1_Click(object sender, EventArgs e) { string path = ""; SaveFileDialog savefiledialg = new SaveFileDialog(); label1.Text = "Save"; savefiledialg.ShowDialog(); label1.Text = "Open"; OpenFileDialog openFileDialog1 = new OpenFileDialog(); if (openFileDialog1.ShowDialog() == DialogResult.OK) { path = openFileDialog1.FileName; } else { return; } } compiled using visual studio 2012 and for .NET Framework 3.5 the "details" of the crash message is : See the end of this message for details on invoking \njust-in-time (JIT) debugging instead of this dialog box.\n\n************** Exception Text **************\nSystem.ArgumentException: Value does not fall within the expected range. at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (System.Int32 errorCode) [0x0000a] in <7713cb95b33244ed9608bf0b23fbdce9>:0 at (wrapper cominterop) System.Windows.Forms.FileDialogNative+IFileDialog.SetFileTypes(uint,System.Windows.Forms.FileDialogNative/COMDLG_FILTERSPEC[]) at (wrapper cominterop-invoke) System.Windows.Forms.FileDialogNative+IFileDialog.SetFileTypes(uint,System.Windows.Forms.FileDialogNative/COMDLG_FILTERSPEC[]) at System.Windows.Forms.FileDialog.SetFileTypes (System.Windows.Forms.FileDialogNative+IFileDialog dialog) [0x00008] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.FileDialog.OnBeforeVistaDialog (System.Windows.Forms.FileDialogNative+IFileDialog dialog) [0x0006e] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.FileDialog.RunDialogVista (System.IntPtr hWndOwner) [0x00008] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.FileDialog.RunDialog (System.IntPtr hWndOwner) [0x00038] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.CommonDialog.ShowDialog (System.Windows.Forms.IWin32Window owner) [0x000f0] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.CommonDialog.ShowDialog () [0x00000] in <4b7d326f792d4378bd436300c6961411>:0 at (wrapper remoting-invoke-with-check) System.Windows.Forms.CommonDialog.ShowDialog() at WindowsFormsApplication15.Form1.button1_Click (System.Object sender, System.EventArgs e) [0x0001e] in <fab84d9a41fb43a5a0d481a535d563b1>:0 at System.Windows.Forms.Control.OnClick (System.EventArgs e) [0x0001f] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.Button.OnClick (System.EventArgs e) [0x00037] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.Button.OnMouseUp (System.Windows.Forms.MouseEventArgs mevent) [0x0009a] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.Control.WmMouseUp (System.Windows.Forms.Message& m, System.Windows.Forms.MouseButtons button, System.Int32 clicks) [0x001c3] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x005a0] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.ButtonBase.WndProc (System.Windows.Forms.Message& m) [0x0011f] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.Button.WndProc (System.Windows.Forms.Message& m) [0x00056] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.Control+ControlNativeWindow.OnMessage (System.Windows.Forms.Message& m) [0x00001] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x000b3] in <4b7d326f792d4378bd436300c6961411>:0 at System.Windows.Forms.NativeWindow.Callback (System.Windows.Forms.Message& m) [0x00025] in <4b7d326f792d4378bd436300c6961411>:0 \n************** Loaded Assemblies **************\nmscorlib\n Assembly Version: 4.0.0.0\n Win32 Version: 4.6.57.0\n CodeBase: file:///C:/windows/mono/mono-2.0/lib/mono/4.5/mscorlib.dll\n----------------------------------------\nWindowsFormsApplication15\n Assembly Version: 1.0.0.0\n Win32 Version: 1.0.0.0\n CodeBase: file:///Z:/home/test/Downloads/WindowsFormsApplication3.exe\n----------------------------------------\nSystem.Windows.Forms\n Assembly Version: 4.0.0.0\n Win32 Version: 4.6.57.0\n CodeBase: file:///C:/windows/mono/mono-2.0/lib/mono/gac/System.Windows.Forms/4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll\n----------------------------------------\nSystem\n Assembly Version: 4.0.0.0\n Win32 Version: 4.6.57.0\n CodeBase: file:///C:/windows/mono/mono-2.0/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll\n----------------------------------------\nSystem.Drawing\n Assembly Version: 4.0.0.0\n Win32 Version: 4.6.57.0\n CodeBase: file:///C:/windows/mono/mono-2.0/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll\n----------------------------------------\nAccessibility\n Assembly Version: 4.0.0.0\n Win32 Version: \n CodeBase: file:///C:/windows/mono/mono-2.0/lib/mono/gac/Accessibility/4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll\n----------------------------------------\nSystem.Configuration\n Assembly Version: 4.0.0.0\n Win32 Version: 4.6.57.0\n CodeBase: file:///C:/windows/mono/mono-2.0/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll\n----------------------------------------\n\n************** JIT Debugging **************\n -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #1 from forinih564(a)nic58.com --- Created attachment 68491 --> https://bugs.winehq.org/attachment.cgi?id=68491 Crash screenshot -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #2 from forinih564(a)nic58.com --- Created attachment 68492 --> https://bugs.winehq.org/attachment.cgi?id=68492 The terminal output -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 forinih564(a)nic58.com changed: What |Removed |Added ---------------------------------------------------------------------------- Distribution|--- |Ubuntu --- Comment #3 from forinih564(a)nic58.com --- still occurs with wine 6.0rc -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #4 from forinih564(a)nic58.com --- (In reply to forinih564 from comment #3)
still occurs with wine 6.0rc
wine 6.0 rc2 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 Nikolay Sivov <bunglehead(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #5 from Nikolay Sivov <bunglehead(a)gmail.com> --- There is an explicit throw in WinForms Core code for this: --- private void SetFileTypes(IFileDialog dialog) { COMDLG_FILTERSPEC[] filterItems = FilterItems; HRESULT hr = dialog.SetFileTypes((uint)filterItems.Length, filterItems); if (!hr.Succeeded()) { throw Marshal.GetExceptionForHR((int)hr); } --- SetFileTypes fails because filterItems is null, and it should according to tests. Running with .NET winforms I get this: 0420:trace:commdlg:IFileDialog2_fnSetFileTypes 00CF3A48 (0, FFFFFFFF) Which returns S_OK in Wine, because of 0 first argument while second is non-zero. I don't know if it points to difference between managed part of WinForms Core vs WinForms .NET, or if it's about marshalling logic differences in mono vs .NET runtime. Confirming. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 Nikolay Sivov <bunglehead(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Wine fails to execute .NET |Vista+ style file dialogs |C# "ShowDialog()" |fail to open with wine-mono Version|unspecified |6.0-rc2 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #6 from Bruni <earns.61(a)gmail.com> --- --quote-- [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Invoke or BeginInvoke cannot be called on a control until the window handle has been created. --quote-- Maybe marshaled exception prevents Invoke from accessing the form thread. Nikolay, could you please try to suppress the marshaled exception and post renewed stacktrace? -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #7 from Nikolay Sivov <bunglehead(a)gmail.com> --- I already tried returning S_OK from SetFileTypes() in comdlg32, and that helps. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #8 from Bruni <earns.61(a)gmail.com> --- Nikolay What say? GetExceptionForHR is a way to convert HRESULT error into an exception. Exceptions propagate through stack up to the entry point until some code catches them. Microsoft implies the aim of GetExceptionForHR is to create exceptions that are not to be caught. See https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.m... This bug means the absence (or unfitness) of a catch block. Microsoft do not seemingly specify any GetExceptionForHR call in winforms\Managed\System\WinForms\FileDialog_Vista.cs as well. See https://referencesource.microsoft.com/#system.windows.forms/winforms/Managed... This is how SetFileTypes looks on that page: private void SetFileTypes(FileDialogNative.IFileDialog dialog) { FileDialogNative.COMDLG_FILTERSPEC[] filterItems = FilterItems; dialog.SetFileTypes((uint)filterItems.Length, filterItems); if (filterItems.Length > 0) { dialog.SetFileTypeIndex(unchecked((uint)filterIndex)); } } } So it seems native .NET gets by without a marchaled (and uncatchable) exception in SetFileTypes. There may always be something left out of account but some explanation of `throw Marshal.GetExceptionForHR((int)hr);` is needed. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #9 from Nikolay Sivov <bunglehead(a)gmail.com> --- If there is truly a difference between winforms in Framework vs Core, it should be possible to verify that on Windows. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #10 from Bruni <earns.61(a)gmail.com> ---
If there is truly a difference between winforms in Framework vs Core, it should be possible to verify that on Windows.
The program from https://bugs.winehq.org/show_bug.cgi?id=50042#c0 opens two file dialogs in series on Windows 7. No exception. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #11 from Nikolay Sivov <bunglehead(a)gmail.com> --- (In reply to Bruni from comment #10)
If there is truly a difference between winforms in Framework vs Core, it should be possible to verify that on Windows.
The program from https://bugs.winehq.org/show_bug.cgi?id=50042#c0 opens two file dialogs in series on Windows 7. No exception.
Does that contradict my comment? -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #12 from Bruni <earns.61(a)gmail.com> ---
Does that contradict my comment?
Sorry, I don't understand the question. What has been done, is a launch of dnSpy on WindowsFormsApplication3.exe -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #13 from forinih564(a)nic58.com --- (In reply to Bruni from comment #6)
--quote-- [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Invoke or BeginInvoke cannot be called on a control until the window handle has been created. --quote--
Maybe marshaled exception prevents Invoke from accessing the form thread.
Nikolay, could you please try to suppress the marshaled exception and post renewed stacktrace?
I just noticed this message is printed only after attempting to close the program after the error messagebox shows if i press continue to the error message then close the program , the message is printed to the console , the program closes but doesn't return control to terminal , i have to kill it via ctrl+c in this case the program is responsive (before closing it) & when pressing the button again, the same error message box appears if i press quit , the message is printed however the program is still visible & unresponsive , i have to kill it via ctrl+c in terminal -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #14 from Bruni <earns.61(a)gmail.com> --- (In reply to forinih564 from comment #13)
(In reply to Bruni from comment #6)
--quote-- [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Invoke or BeginInvoke cannot be called on a control until the window handle has been created. --quote--
Maybe marshaled exception prevents Invoke from accessing the form thread.
Nikolay, could you please try to suppress the marshaled exception and post renewed stacktrace?
I just noticed this message is printed only after attempting to close the program after the error messagebox shows
if i press continue to the error message then close the program , the message is printed to the console , the program closes but doesn't return control to terminal , i have to kill it via ctrl+c in this case the program is responsive (before closing it) & when pressing the button again, the same error message box appears
if i press quit , the message is printed however the program is still visible & unresponsive , i have to kill it via ctrl+c in terminal
This exception seems to be a consequence of the System.ArgumentException the cause of which is yet to be identified. Microsoft gave the same names to methods in COM objects and NET components. To give an example, there is a method named CreateVistaDialog both in dotnet /System/Windows/Forms/FileDialog_Vista.cs an in the COM object providing dialog functionality. Windows Forms (WinForms) is a UI framework for building Windows desktop applications. It is a .NET wrapper over Windows user interface libraries, such as User32 and GDI+ according to https://github.com/dotnet/winforms/blob/master/README.md So you have to find out whether you're in COM or NET part when debugging. Different signatures may give you some guess. Moreover, there is no managed code implementation for SetFileTypes with two parameters in https://referencesource.microsoft.com/#system.windows.forms/winforms/Managed..., in https://github.com/dotnet/winforms, in SetFileTypes https://github.com/mono/mono When placed on a class, the ComImport attribute marks the class as an externally implemented Com class. Such a class declaration enables the use of a C# name to refer to a COM class. A class that is decorated with the ComImport attribute is subject to the following restrictions: It must also be decorated with the Guid attribute, which specifies the CLSID for the COM class being imported. A compile-time error occurs if a class declaration includes the ComImport attribute but fails to include the Guid attribute. It must not have any members. (A public constructor with no parameters is automatically provided.) It must not derive from a class other than object. (from https://www.c-sharpcorner.com/article/interface-components-interoperability/) In comment 5 Nikolay said that SetFileTypes fails because filterItems is null, and it should according to tests:
--- private void SetFileTypes(IFileDialog dialog) { COMDLG_FILTERSPEC[] filterItems = FilterItems; HRESULT hr = dialog.SetFileTypes((uint)filterItems.Length, filterItems); if (!hr.Succeeded()) { throw Marshal.GetExceptionForHR((int)hr); } ---
There are two places where exceptions may be thrown due to filterItems being null - filterItems.Length and dialog.SetFileTypes. Failing tests means that wine does not expect FilterItems to return null. Perhaps a testcase for FilterItems (both for COM and NET part) is needed. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #15 from Bruni <earns.61(a)gmail.com> --- Please run this command in bash on your program WINE_MONO_TRACE=all WINEDEBUG=+seh,+relay,+loaddll,+mscoree wine ./WindowsFormsApplication3.exe >>log.txt 2>&1 and attach the output -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #16 from Nikolay Sivov <bunglehead(a)gmail.com> --- (In reply to Bruni from comment #15)
Please run this command in bash on your program
WINE_MONO_TRACE=all WINEDEBUG=+seh,+relay,+loaddll,+mscoree wine ./WindowsFormsApplication3.exe >>log.txt 2>&1
and attach the output
The program is attached, so I think you should be able to do that. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #17 from forinih564(a)nic58.com --- Created attachment 69184 --> https://bugs.winehq.org/attachment.cgi?id=69184 assertion fail screenshot (In reply to Bruni from comment #15)
Please run this command in bash on your program
WINE_MONO_TRACE=all WINEDEBUG=+seh,+relay,+loaddll,+mscoree wine ./WindowsFormsApplication3.exe >>log.txt 2>&1
and attach the output
after typing the command , the program takes around 5 minutes to launch & show the ui , then after pressing the button & waiting for 20 minutes , i get the crash shown in the screen shot , viewing the details the error message is Unhandled exception: assertion failed in 32-bit code (0xf7f84b49). -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #18 from forinih564(a)nic58.com --- Created attachment 69185 --> https://bugs.winehq.org/attachment.cgi?id=69185 assertion fail backtrace the log file generated by the command is around 4Gib , should i attach it? -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #19 from Bruni <earns.61(a)gmail.com> --- Now please run awk '{lc=tolower($0)}; (lc ~ /Marshal/) || (lc ~ /SetFileTypes/) || (lc ~ /Exception/) || (lc ~ /handle/) || (lc ~ /wrapper/) {print NR, $0}' log.txt > shrinked_log.txt in the folder with log.txt -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #20 from forinih564(a)nic58.com --- Created attachment 69187 --> https://bugs.winehq.org/attachment.cgi?id=69187 shrinked_log I hope that helps -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=50042 --- Comment #21 from forinih564(a)nic58.com --- Still occurs with wine 6.3 , the log is the same except that there is an extra "00a4:err:rpc:I_RpcReceive we got fault packet with status 0x1c010003" at the end -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
WineHQ Bugzilla