visual studio 2012: Help needed with projects and solution explorer - c#

Hi iam new to visiual studio, and for my studies i have one centered with c#.It is not a difficult questions
firstly wheneveri start a new project through file->NEW->projects all other projects in the document disapears. anyway to keep them?
secondly whenever without any problem when i start new projects the solution explorer shows its contexts without problem, but how do i show the contents of other projects opened aswell?
thanks in advance hope it is not vague.

By doing this "file->NEW->projects" you are opening a new solution if you don't
change the solution property to "Create new solution" to "Add to solution".
By selecting "Add to solution" you can add new project to you existing solution.
also you can right click the existing solution and add new project to it.

Right click on your solution and then click on Add. Then select Existing project and add your project into the solution. Then you will be able to see all the projects opened at the same time.

Related

How to create new project for current class library without having to create a solution?

I have setup an class library project in visual studio so I can make a custom hyperlink [the built in one doesn't have what i need]. I want to now make a demo project to test it but I want to be able to do it without having to create a whole new project. How can I do that?
For what you want you just need to create a new project in the same solution.
If the solution is not seen in the Solution Explorer, you can enable the option to always show it here:
Open the Tools menu.
Press the Options item.
Expand the Projects and Solutions tree node and select the General tree node.
Tick the Always show solution check box.
Now you can just right-click your solution in the Solution Explorer and press Add and New project.
MSDN Reference to adding projects to a solution: https://msdn.microsoft.com/en-us/library/ff460187(v=vs.100).aspx
Whenever you create almost any type of new project in Visual Studio, a Solution is created for you;
A Solution is a structure for organizing projects in Visual Studio...
This means that multiple Projects (and Projects of different types) can exist within a single Solution. You can see the link above for steps on how to do this, or you can follow the steps listed below:
Open Solution Explorer from the View menu in Visual Studio [if it isn't already open];
Right-click the Solution in Solution Explorer. The Solution, as far as I am aware, is always the first item in the list;
Navigate to Add > New Project...:
;
Follow the steps to create your desired Project;
And that's it.
Don't forget to right-click the new Project in Solution Explorer and select Set as StartUp Project if you want to Run or Debug it:

I can't find the form that I built

I'm using Visual Studio 2013 and I created a windows form application. Everything was fine until just now. When I go into my project now I cannot find the Form1.cs [Design] tab which allows actual form designing with the rag and drop of object from the toolbox.
I checked the directory and I do have files and sub-directories, but being a C# beginner, I'm not too familiar with what files are needed.
So, could someone please show me how to get this back?
Thanks.
This is pretty vague. But if it isn't in your solution explorer, re add the files to the project.
Right Click on your project root -> New -> From Existing Item, navigate to said item and add it. (shortcut is Shift + Alt + A).
If it's just code right click on it and select "View Designer", if you still have trouble try posting a screenshot.

How to edit .csproj file

When I am compiling my .csproj file using .NET Framework 4.0 MSBUILD.EXE file, I am getting an error: "lable01" not found in the current context of "website01.csproj".
Actually, I need to add every ASP.NET page with its code-behind file's reference. I've done it, it's working fine, but the above error is pending.
I hope it means that I need to add form name "LABLE01" in that .csproj file, but I do not know the syntax. Anybody please do provide me with the syntax to add form name in .csproj file.
The CSPROJ file, saved in XML format, stores all the references for your project including your compilation options. There is also an SLN file, which stores information about projects that make up your solution.
If you are using Visual Studio and you have the need to view or edit your CSPROJ file, while in Visual Studio, you can do so by following these simple steps:
Right-click on your project in solution explorer and select Unload Project
Right-click on the project (tagged as unavailable in solution explorer) and click "Edit yourproj.csproj". This will open up your CSPROJ file for editing.
After making the changes you want, save, and close the file. Right-click again on the node and choose Reload Project when done.
Since the question is not directly mentioning Visual Studio, I will post how to do this in JetBrains Rider.
From context menu
Right-click your project
Go to edit
Edit '{project-name.csproj}'
With shortcut
Select project
Press F4
You can right click the project file, select "Unload project" then you can open the file directly for editing by selecting "Edit project name.csproj".
You will have to load the project back after you have saved your changes in order for it to compile.
See How to: Unload and Reload Projects on MSDN.
Since project files are XML files, you can also simply edit them using any text editor that supports Unicode (notepad, notepad++ etc...)
However, I would be very reluctant to edit these files by hand - use the Solution explorer for this if at all possible. If you have errors and you know how to fix them manually, go ahead, but be aware that you can completely ruin the project file if you don't know exactly what you are doing.
There is an easier way so you don't have to unload the project. Just install this tool called EditProj in Visual Studio:
https://marketplace.visualstudio.com/items?itemName=EdMunoz.EditProj
Then right click edit you will have a new menu item Edit Project File :)
in vs 2019 Version 16.8.2
right click on you project name
and click on "Edit Project File"
Here is my option to Edit the project file without the need to Unload the project:
Open Solution Explorer and switch to folder view:
Navigate to the Project which you want to edit inside the Solution folders and right-click on it.
Choose Open from the Context Menu.
That is it!
You will see the *.csproj file opened inside Visual Studio Editor.
After you can switch back to a Solution/Project view (see step 1).
Update:
Starting from the Visual Studio 2019 (v. 16) you can edit the *.csproj file by double-clicking on the Project, just make sure that you have the option turned On from the settings.
For JetBrains Rider:
First Option
Unload Project
Double click the unloaded project
Second option:
Click on the project
Press F4
That's it!
Sorry, most efficient way with out stuffing your proj file is.
right click the file.
goto properties
where Build Action option is set it to NONE.
Do a build (yes you may get build error if you do even better)
go back to properties of that file
set Build Action option is set it back to Compile.
rebuild.
Congratulate your self for being smarter than everyone else and not ****ing you project. For me this exercise took under 10 seconds. Where as manually trying to input the compile... line into the csproj not only can render your project unusable but it is also impossible to maintain on large scale application. Better to keep source version control software to do the updates. If you need to cross merge branches then doing the above is amazing :).
To open the .csproj file:
open the solution explorer
1
Click on the Edit Project File option
2
You can also open the .csproj by double-clicking on the project file. So no need to right click and select edit project file. Just double click and that is it.
It is a built-in option .Net core and .Net standard projects
For Visual Studio-version: 8.1.5,
Right click on the project folder.
Click "Tools", then "Edit File".
A little late to the conversation but I found a better option.
In rider you can enable "open project files with single click"
Just go to the solution options menu and then click in open project files with single click

How can I open a project without opening its associated solution in Visual Studio?

I have a solution that contains few projects.
The problem is that when I want to open just one of the projects by clicking on the specific .csproj file, it opens all the solution.
How can I open just one project?
Thanks.
You can create a new solution, and add this project to the solution.
Then this project will have a solution of it's own.
It's a hack but rename the .sln file to some other extension temporarily, then double click the csproj. Visual Studio seems to have intellismarts about detecting solutions.
The only way I have been able to do this is to remove the project from the main solution and save it and close it.
You should now be able to open the solution and the project file independently.
Note: opening the csproj file will create a new solution for you.
Why do I want to open a single project from a solution?
I have a solution with 66 subprojects, so it is helpful if you can only edit a single project. I have already tried many possibilities, as described above.
Today I mostly do it with the command "Scope to this" in the project explorer. So I have the focus only on one project. So I hope this tip was helpful for you :-)
Depending on your needs. I just want to open the project so I copied the projectfolder to a temp folder and then I just open the project.
But I don't want it in version control and all edits will be lost unless overwrite to the original folder.
You can't. The basic unit of Visual Studio is a solution.

How to make new project and website into only one solution?

How to make new project and website into only one solution?
Create the first project, then in the Solution Explorer you can right-click the solution and "Add new project" to it.
First create the WebSite, it will have a Solution (.sln file) but under the default settings it could be located far away from your WebSite folders.
Then add a Project to your solution like normal. If that project is a class library you will have to select it from "Add Reference, Projects tab" as well.
Conversely, you can start with a 'normal' Project and select "Add existing WebSite" from the "File" menu or the Solutions context menu.

Categories