Where is debug start action options in a C# DLL project for Visual Studio 2022

Jackie Yang 21 Reputation points
2022-01-25T20:21:25.81+00:00

It seems that with the new interface for "debug profiles UI" in Visual Studio 2022, I can no longer find the start action options (https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-debug-from-a-dll-project?view=vs-2022#specify-a-calling-app-in-a-managed-dll-project).

Any idea where is the new location of the start action options?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,705 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,391 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
952 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 49,251 Reputation points
    2022-01-25T22:17:35.277+00:00

    Yes, for SDK-based projects the new launch profile UI is really confusing. They are trying to get it to behave like VS Code and it is a ways off.

    To configure a DLL project to be debuggable (instead of having a corresponding unit test or test app project) you need to go to the launch profile UI dialog via the project properties or Debug menu. Once in the UI you should have a default profile for the class library but this doesn't work for DLLs. Add a new profile from the toolbar at the top and select Executable. Then you can enter executable information like you could before. Behind the scenes it is just updating the launchsettings.json so you could also just edit that file directly.

    At least with the current version of VS 2022 you cannot select the profile to run against when you debug (like you can for VS Code). The only way I have found to work around this is to delete the auto-generated profile that was created. It appears the debugger first tries to use the profile matching the project name. If it doesn't find it uses the first one it finds but I could be wrong about this.

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Reza Aghaei 4,936 Reputation points MVP
    2023-01-28T22:03:31.7133333+00:00

    VS shows different Debug start actions for different project formats:

    • The project files with MSBuild project format will use the old Debug settings window.
    • The project files with SDK project format will use the new Debug settings window.

    All the project that you create using new project templates for .NET Core and .NET >=5 will use SDK style. But the .NET Framework project templates are still using MSBuild project format by default; however, one may modify the project format to SDK style for .NET 4.8 project as well. Then in this case, VS shows the new Debug start actions for .NET 4.8 as well.

    How to set StartAction for SDK style projects?

    In project properties, go to Debug section, Genera, and click on "Open debug lunch profile UI".

    • You can specify command line argument for the current debug profile
    • Or you can create a new profile (Executable) and specify the executable if you want (like specifying VS, when you want to debug design time of VS).

    After you created the new profile, you can just choose any profile from debug toolbar dropdown button and start that profile.

    Here is the project properties > Debug > General section

    enter image description here

    A new executable profile added, to start VS for example to debug design time features of a control

    enter image description here

    You can set the command line argument

    User's image

    For your startup project, you can choose the profile

    enter image description here

    Above, is tested on:

    Microsoft Visual Studio Professional 2022 (64-bit) - Current
    Version 17.4.4
    
    1 person found this answer helpful.
    0 comments No comments