Visual Studio 2010 wants to start project as class library - c#

sometimes i have problems with the debug.
I have a solution with some projects (1 WPF application, 1 console application and some libraries - the console application host some services and the wpf application is the client).
If i want debug the client (or the host) visual studio means it can not be started because it is a class library. But after some tries and restarts of Visual Studio i can debug one of the projects without problems!
Is there a solution for this problem?
Mfg
edit#1: i have already set a startup project. If i want to debug the client, the host will be the startup project. If i want to debug the host, the client will be the startup project.

When using Visual Studio 2010 (probably even before that ;)), you can specify multiple startup projects. Just right click on the solution, click Set Startup Projects and choose radio button item Multiple startup projects. You can now set the Action property to Start (with or without debugging) for all projects you like.

If you are just hitting debug and haven't set a default debug start project, then it will try and debug the current project, which may well be a class library.
Set the default project by right cliking on a project in SOlutions Explorer and Set As StartUp Project.

Related

Visual Studio Esproj - Debug only launching esproj

I've a solution with 2 projects, .net7 api and a vue esproj
When I set the startup project as the .net 7 api, Visual Studio changes to the .esproj and launches it instead of the api.
Any ideas why is this happening?
There may be a project in the solution that depends on another project, and you set the startup project of the dependent project. This means that when you start a dependent project, Visual Studio automatically starts the dependent project as well.
Apparently you have some wrong settings in your user settings.
So the fix for this issue is to remove the user settings from the solution and run again.

How to Create a visual studio Setup Project to install multiple Windows Services

I have 3 windows service with separate solutions. How can I install all the three with one visual studio Setup Project.
It's not clear why this is a difficulty, but perhaps you are stuck with the idea that the "project output" idea in a setup project means that you can have only one solution's output in a setup project.
The easiest thing to do is to create the setup project and then add (to the Application Folder) each of the service executables (which I assume have installer classes). Then add the three service executable installer classes as custom actions. To state the obvious, you allowed to have more than one custom action to install a service.

Get Windows Forms App project in Visual Studio to run from form, rather than having to open up Visual Studio?

I've created a Windows Forms App which after a lot of testing can now be deployed and used in production.
When I have tested the solution, it has been by using F5 in Visual Studio, which then has opened up my Form.
In my Form I have an option to add some files, and then press "Run application".There is a C# script in the background which gathers data from these files and make some operations on them.
I have checked where my Solution is saved on my computer. Here I can see that I have some .cs files (and some other extensions such as .resx) corresponding to my Form, but no actual "Form" to run (as in open up the Form, and run it as I would by pressing F5 in Visual Studio).
I've been trying to find answers to my questions from Googling, but with now avail.
Can I, instead of opening up Visual Studio and run the solution, run the solution from the Form itself, i.e. open up the Form which is created when I run the program in Visual Studio? If this is possible, can I make shortcuts on for instance the Desktop with the Form?
If it is possible to use a Form as an executable file, do I have the option to deploy the Form itself to some folder, and the rest of the Project files to the same folder they are saved in now?
As mentioned in a comment - when you build the project it should create a .exe file named for the project (not the form). this would normally be built under <source>\bin\<configuration> - so c:\projects\my_app\bin\debug for example (this CAN be changed in the project properties page on the Build tab though). The startup form for the project would normally be governed by the code in the Program Static class in the Program.cs file for the project.

C# Interactive - Project References and Settings

With the Visual Studio 2015 Update 1 there now is a C# Interactive tool window built into Visual Studio.
The new tool window is invoked by going to View → Other Windows → C# Interactive.
Is there any way to have the C# Interactive tool load the set of references, app settings, IOC config etc. for a project in the solution?
This only works for .NET Framework projects:
You can context-click a project in your solution explorer and choose "Initialize interactive with project". Then the interactive window will load all references and your project's dll.
It will only load the dlls, no config. You could still do that manually though, aswell as the IOC config, by calling the startup.cs yourself.
This doesn't work for .NET Core or .NET standard projects.

Post Publish Events

For normal (say Windows Forms) C# applications, to execute commands after a successful build I would use the Build Events->Post-build event command line in Project Properties.
I have a Web Site project which I "Publish", using the "Publish..." command in the context menu in the solution explorer.
Is there a way to run commands after the successful publish and if so how is it done? (eg a Post-Publish event command line field)
Visual Studio 2008, ASP .Net Web site project, C#.
Update: Since Publish Web does not apply to folder-based web site projects, this answer assumes you are asking about a Web Application project.
You can't do this from inside the VS IDE. However, you can edit your project file in Notepad or your favorite XML editor and add a new target at the end of the file called AfterPublish.
You might want to read a bit more on MSBuild if you are not sure what you can do in this target.
You can find more details on extending the build process in VS at MSDN - HowTo: Extend the Visual Studio Build Process.

Categories