Search code examples
c#visual-studiowinformsvisual-studio-debuggingmsix

MSIX package and debugger are starting in the wrong project


I have a WinForms application solution with three projects. This is running on .NET 5.

  1. Startup project: handles user authentication and provides a basic menu and layout. All forms are stored and loaded by another project
  2. Forms project: stores all of the forms that the user will interact with
  3. Data layer project that stores all of the entities and DbContext references

In the MSIX installer package, I have specified the startup project as the only application project and set it as the startup project. However, there have been some problems with the compiled application not running correctly. When I started debugging the application through the MSIX package, I noticed that it was always starting in the Forms project, and completely bypassing the startup project. This should not be happening. How do I prevent both the MSIX package and the debugger from starting in the wrong project?

Note: I am running Windows 10 and Visual Studio Community 2019.


Solution

  • We are not sure why this problem is occurring. We think this is a bug with the MSIX package. At any rate, we found that the two projects in question were being built as executables, but we only need one. So, for the project that was starting incorrectly, we went into the Application window (right click the project and select properties) and we set the output type to class library as opposed to Windows Application.

    This resolved the problem. But, the MSIX package still seems to not handle the Set as Startup flag correctly when more than one project has an output type of Windows Application.