Trimmable - Winforms crash on startup
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 49
Description
Release Type: Official Release
Version: 4.2.0.2188
Platform(s): Windows
Describe the bug
Publish Trimmable seems to remove something that Winforms needs to properly function.
To Reproduce
Steps to reproduce the behavior:
- use a default project
- publish with the trimmable option set to true
Publish Trimmable
Expected behavior
Crash bad. No crash good.
Log and callstacks
System.InvalidCastException: Specified cast is not valid.
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo)
at Windows.Win32.Foundation.HRESULT.ThrowOnFailure(IntPtr errorInfo)
at Windows.Win32.ComHelpers.GetComPointer[T](Object object)
at Windows.Win32.ComHelpers.GetComScope[T](Object object)
at System.Windows.Forms.RichTextBox.UpdateOleCallback()
at System.Windows.Forms.RichTextBox.OnHandleCreated(EventArgs e)
at System.Windows.Forms.Control.WmCreate(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)
Additional context
This was found by Discord user DraftedDev and discussed in Discord (https://discord.com/channels/500285081265635328/500292370923913222/1286008639303192628)
Apparently the Trimmable option only affects Winforms as SDL worked.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the crash in a default Windows project using the Publish Trimmable option, then inspect the stack beginning at System.Windows.Forms.RichTextBox.UpdateOleCallback. Compare trimmable and non-trimmable publishes and verify that the published WinForms application starts without the reported InvalidCastException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100