What is a C # solution and how to use it?

I am new to C # (from Python and C), and when I start a new project in Monodevelop or Visual Studio, the project is placed in the "solution" container.

I took a look at Microsoft's description of what such a solution is, but I really don't understand its advantages and how I should use it.

Microsoft documentation reports:

The project is contained in a logical sense and in the file system as part of a solution that can contain one or more projects, as well as assembly information, Visual Studio window options and any different files that are not associated with any project. In a literal sense, the solution is a text file with its own unique format; it is usually not intended for manual editing.

Can someone explain what the β€œsolution” is for here?

+6
source share
7 answers

A solution is a workspace that integrates several projects that are usually related to each other. The design is very useful in situations where some code needs to be exchanged between several projects.

For example, if you are developing a website with a separate server component, you can select it in several related projects:

  • A project containing common interfaces creating a DLL
  • A project containing a database definition, creating an RDBMS deployment script
  • A project containing a server-side API implementation that creates an executable
  • Website project creating IIS script deployment

These four projects are related to each other. Placing them in a single solution allows you to access the individual parts, using the general indexing, which Visual Studio does to simplify the search and use of refactoring.

+4
source

The solution is the "Container" for your projects.

For example: if you are writing a Windows application, you may have one project for the user interface and one project for the backend logic.

To easily work on both projects, you have included them in one solution, which allows you to not only debug both projects, but also create them in the order you specify.

+2
source

<strong> Benefits

Solutions allow you to focus on the development and deployment of projects, rather than sorting all the management details of the project files, components and objects. Each Visual Studio solution allows you to:

Work on multiple projects in one instance of the IDE.

Work with elements that use settings and parameters that apply to the entire set of projects.

Use Solution Explorer to help develop and deploy your application.

Manage additional files open outside the context of a solution or project.

Read the full article for more details: Solutions as Containers

+2
source

Although all the other answers are correct, I feel that they lack a conceptual reason.

The project is an independent part of the work, it can be an application of Win forms, a class library, a website, a web service, etc.

However, solving the problem may require several parts, i.e. Win Forms requires the class library to work, and so a web service may need a web service other than a Web site.

The decision file is a conceptualized model of this,

If your problem is a Winforms application, you create a solution and add a winforms application and a library

if your problem is with the website, then you create a solution and add the website to the web service and library

the project containing the library may be the same in both solutions, which means that you don’t need to duplicate the code or keep track of the dependencies for your projects, because everything it depends on is already in your solution

+2
source

The solution combines all your projects (dlls), files, configs, etc., the quote you provided does not require any explanation:

The project is contained in a logical sense and in the file system as part of the solution ...

+1
source

The solution contains one or more projects. For example, the solution includes a web project, a mobile project, and a Windows service project. So, the solution to my application has 3 projects.

+1
source

The advantage of the solution is that you can add several projects to it. This is good if you have a project that uses your own libraries.

Then your solution will contain your main project and your projects in the library. And they can all depend on each other so that they are built in the correct order.

Without a solution, you will only have your main project, and you will have to create your libraries separately

+1
source

Source: https://habr.com/ru/post/1011981/


All Articles