dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.31k stars 956 forks source link

Single instance app doesn't work when same app is in different folders #11365

Open luronumen opened 2 months ago

luronumen commented 2 months ago

.NET version

.NET 8.0.204

Did it work in .NET Framework?

Yes

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

No response

Issue description

Single instance app doesn't work when same app is in different folders

Steps to reproduce

  1. Create a WinForm Application for .NET 8.0 (e.g.: WinFormsApp1)
  2. Implement the Single Instance Application using the Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase class;
  3. Build the Project and copy the bin\Debug\net8.0-windows folder for 2 diferent folders (e.g.: FolderA and FolderB);
  4. Launch the WinFormsApp1.exe from FolderA and keep it opened;
  5. Try to launch the WinFormsApp1.exe from FolderA again: Verify that it is detected that the WinFormsApp1.exe is already opened (PASS!);
  6. Now, Launch the WinFormsApp1.exe from FolderB: Verify that WinFormsApp1.exe is launched and 2 instances of the WinFormsApp1.exe are now opened. One from FolderA and other from FolderB (FAIL);

IMPORTANT NOTES

Here is the code exemple to reproduce this issue: WinFormsApp1.zip

elachlan commented 2 months ago

Related: #11232

elachlan commented 2 months ago

@merriemcgaw Do we want Single Instance VB apps to work similarly to framework here? I imagine we can just hash the file path to the app as a GUID.

merriemcgaw commented 2 months ago

Let me run this by @KlausLoeffelmann, but I think it's quite reasonable and might even be a blocker for some migrations.

KlausLoeffelmann commented 5 days ago

Might be also Migration Blockers for Citrix/Terminal Server scenarios, because they would act out for the same reason. @paul1956 actually had also some ideas and concerns, if I remember correctly. We should aim for the .NET 10-time frame to take care of this.