question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[8.0.100-alpha.1.23056.11] Form opens multiple times when launched from UserControl with EventHandler in AutoVersionsDB App

See original GitHub issue

.NET version

.NET SDK:
Version:   8.0.100-alpha.1.23056.11
Commit:    7bea0af7fe 

Runtime Environment:
OS Name:     Windows
OS Version:  10.0.19045
OS Platform: Windows
RID:         win10-x64
Base Path:   C:\Program Files\dotnet\sdk\8.0.100-alpha.1.23056.11\ 

Host:
  Version:      8.0.0-alpha.1.23055.3
  Architecture: x64
  Commit:       9197fd5551 

.NET SDKs installed:
  8.0.100-alpha.1.23056.11 [C:\Program Files\dotnet\sdk] 

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.0-alpha.1.23055.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.0-alpha.1.23055.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 8.0.0-alpha.1.23055.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] 

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Yes

Verify Scenarios: 1). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.100-alpha.1.23060.31: Fail 2). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.100-alpha.1.23056.11: Fail 3). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.100-alpha.1.23053.3: Pass 4) Windows 10 21H2 AMD64 + dotnet-sdk-7.0.102-win-x64: Pass 5). Windows 10 21H2 AMD64 + dotnet-sdk-6.0.405-win-x64: Pass 6). Windows 10 21H2 AMD64 + dotnet-sdk-5.0.505-win-x64: Pass

Issue description

When testing the 3rd party app AutoVersionsDB with latest .NET 8 runtime, Form opens multiple times when launched from UserControl with EventHandler.

Application Name: AutoVersionsDB OS: Windows 10 21H2 CPU: X64 .NET Build Number: dotnet-sdk-8.0.100-alpha.1.23056.11 App or App Source checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1716419 Github Link: https://github.com/modi-w/AutoVersionsDB

Steps to reproduce

The machine only has 8.0 installed. And DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2 is set.

1.Launch application from “%app_client_root%\AutoVersionsDB\AutoVersionsDB.WinApp.exe”.
2.Click “New Project” button.
3.Type “test” in Id. 4.Click “Save” button. ( if you receive errors, ignore) 5.Click “Menu” icon. 6.Click “DB Process” button. 7.Click “add” button. 8.Click Cancel

Expected Result: Input box should close Actual Result: Input box closes and opens again

Minimal Repro Steps: Minimal repro sample attached: 2605123.zip

  1. Create WinForms App, change the form name to MainForm
  2. Create UserContol, and add this code, also add drag a button to control (button1)
 public partial class UserControl1 : UserControl  //not repro when it is inherit from Form
    {
        MyClass obj = new MyClass();
        public UserControl1()
        {
            InitializeComponent();
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            obj.TestEvent += _OnTestEvent; //if we move this line to constructor, not repro
        }
        private void _OnTestEvent(object sender, EventArgs e)
        {
            Form2 fmr = new Form2();
            fmr.ShowDialog();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            obj.OpenForm();
        }
    }
    public class MyClass
    {
        public event EventHandler<EventArgs> TestEvent;
        public void OpenForm()
        {
            var eventsArgs = new EventArgs();
            TestEvent(this, eventsArgs);
        }
    }
  1. Add UserContol to MainForm
  2. Create another Form for popup window (Form2 )
  3. Add this code to close the from
public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
  1. Build and launch the app
  2. Click button to open window
  3. Close the window

Excepted Result: Pop Up window should close Actual Result: (when we run in NET8, it works when we run on previous versions) Window close and open again

Findings: When we move this line obj.TestEvent += _OnTestEvent; to constructor, issue not repro This issue only repro when we attach EventHandler in UserControl, not repro with Forms.

@dotnet-actwx-bot @dotnet/compat

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
MelonWang1commented, Feb 24, 2023

Verified on latest .NET 8.0.100-preview.2.23123.5 build, issue is fixed. No ‘reopening’ behavior. Screenshot as below: 8489

0reactions
Nora-Zhou01commented, Mar 3, 2023

Verified this on .NET 8.0 Preview 2.0 TP build: 8.0.100-preview.2.23151.8, issue was fixed. No ‘reopening’ behavior. Test result is same as above screenshot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found