Error while removing project dependency in VS2010 - visual-studio-2010

I have a large solution with number of projects.
Some the projects depend on others (never a circular dependency though).
When I tried to remove a dependency of a project, I am getting an error message like "The dependency was added by the project system and cannot be removed". What is the cause for this error? How I can solve this?

I sometimes get this problem when I try to manually edit projects/solutions generated by our CMake system. I solve it manually:
Open the dependent .vcproj file in your favorite text editor.
Find <ProjectReference> tag corresponding to the dependency you want to remove (the include attribute of the tag will contain the name of the dependency project).
Remove the whole <ProjectReference> element (i.e. starting with <ProjectReference> and ending with </ProjectReference> inclusive). Save the file.
Reload the solution.

I faced the same issue. But i could solve it by following
Right click project, select Properties.
Select Framework and References under Common Properties
Select the references thats not needed.
Click on Remove Reference.

Or =>
To remove a reference in Visual C#:
In Solution Explorer, open the References node under the project
node.
Right-click a reference and click Remove
To remove a reference in Visual Basic:
In Solution Explorer, right-click the My Project node for the
project and select Properties.
Click the References tab.
In the References list, select the reference you want to remove.
Click the Remove button

For Visual Studio 2013:
On C++ projects (hope the same for others too)
From the Solution Explorer, select the project and right click to select the properties
In the properties window, on left pane, select Common properties => References
Right side of the window, you have the option to Add or Remove the other dependency items.
Then select OK, to save

If your project only has the .sln file but not any .csproj, you may want to
check the ProjectReferences property and remove the reference project there
remove the section from Project to EndProject
also remove the related rows under GlobalSection(ProjectConfigurationPlatforms)

As an additional point to #malenkiy_scot's above, for ProjectReference items you want to keep, double check the project guid is the correct one for that project. In the dependent .vcproj file, find the ProjectReference tags as above, and for each you want to keep:
open the referenced project's .vcproj file in a text editor
find its guid in the ProjectGuid tag
compare this with Project tag for that reference in the dependent .vcproj file (not case sensitive)
if it's not the same, replace the guid in the Project tag with the one from the referenced project's ProjectGuid tag
save the project file and reload the solution
Visual Studio uses the project guid rather than name to determine dependencies. So if you've hand edited the name of the dependency but not the guid (as I did) you get the error.

In VS17 Right-clicking on the References node then selecting OptimiseReferences... is good for helping work out your dependencies. Also Right-click on the project and clicking BuildDependancies... ProjectDependencies that might be where your dependency is being set.

1- RIght click References of the project and click Add Reference...
2- Uncheck dependent projects from the solution tab

In the solution explorer window, right click on the project and
select "Edit project file". The project.csproj file would open in the editor.
Find the which nests the tag.
Delete the entire (along with the closing tag).

Related

How do I remove files added as link from my project on Visual Studio?

Inside a solution I'm building with Visual Studio 2019, I have a project for a console application. Inside of this project there are references to other files in different solutions, added with the:
Right click on the project → Add → Reference → Existing items → Add as link
option. I'm afraid that using the Remove option (right click on the files) will also delete the original files since I know that adding a file as link will make it as if the two files were literally the same file. How can I remove these references from the project without deleting the original files from the other solutions?
First of all, you could just delete a link with delete, if it's a link it won't delete the original file. (right click, or press delete on the selected file in the solution explorer)
You could see if it's linked by it's icon:
If you really like to do it manually, then you could edit the csproj file and remove the file with the Link attribute, e.g. remove this line:
<Compile Include="somewhere\MyClass.cs" Link="MyClass.cs" />
I'm afraid that using the Remove option (right click on the files) will also delete the original files
Sounds you need a version control system ;)

How To View the Project > References Tab and All DLL Paths in non-VB projects?

When you create a VB project in Visual Studio there is a 'References' tab in the Project Properties window. It looks like this:
It's rather a helpful window as it shows the paths to all the referenced DLLs in one place and lets you add and remove references easily.
However this same tab does not appear for projects in other languages making it very difficult to check the path for each referenced DLL.
Can this tab be made viewable or available for other projects? If not, what is the simplest way to view all the referenced DLL paths at once?
Unfortunately the reference tab for the other languages does not exist.
But you can try to edit the xml project, with these steps:
Show the context menu on your project in the window solution explorer
Select: Unload project
Right click and select Edit
Edit the ProjectReference element in xml file
Save and close xml
Reload Project (right click in solution explorer)
I know this is not what you wanted, but it could be a quick alternative to display the path of your references.

Empty list in visual studio references

I am trying to add a reference and there is no signal reference in the list. It's empty. Also I cannot click browse to add a reference.
Any help? So the list is empty without any references:
Thanks
One solution:
File / New / Project select Win32 Console Application and under Solution select Add Solution:
(image) and click ok. Then click next, clear the Precompiled header checkbox and Finish. Once this project is added to your solution, you will be able to right-click References (under your original project) and see the last project you added available under Projects > Solution.
link:
https://msdn.microsoft.com/en-us/library/ms235627.aspx

Strange "go to sources" behaviour in VS

This is what I get when I select "go to definition" in the ConfigTests.cs. But I expected to go to already opened Config.cs with actual declaration.
What did I do wrong?
You added a normal assembly reference.
When you Go to Definition on a member not defined in your project (or in Project References), Visual Studio will generate a source file from metadata using Reflection.
Delete the reference, then re-add it as a Project reference (in the Projects tab).
If the project isn't in the same solution, put it there.
This seems to indicate that your reference to the Models assembly is via the compiled DLL, not via the project in the solution. Try the following in the Solution Explorer:
Expand (unfold) the “References” item of the main project in your solution.
Select “Models” and press Delete to remove it.
Right-click on “References” and choose “Add Reference”.
Select the Projects tab (not the Browse tab).
Highlight the Models project and click OK.
Of course, this assumes that the Models project is in your solution to begin with. If it isn’t, you will first have to add it by right-clicking the first item in the Solution Explorer (the Solution itself), choosing “Add”, “Existing Project”, and then choosing the right csproj file for the Models project.

change solution file to a different folder

How do I change the folder of my existing solution file (sln)?
It's right now inside one of my project's folder; if I cut the solution file and paste it in the root folder,it doesn't load any of my projects.
Open solution explorer in Visual Studio and select the solution.
Click on File > Save MyProject.sln As ...
and choose the new location.
The solution file is just a text file. You should be able to move it and then edit it to make sure that any relative paths referenced in the file are correct.
I've also been able to right-click on the solution file in the solution explorer and then use save-as to save it in a different location. That doesn't seem to work everytime for me though.
Open a blank solution, save it to a location where you would like to move. Then add "Existing Project" and select the Old.sln file to add all the projects under the old solution file.
I just had to do this with some legacy projects I inherited so thought it might be worth documenting...
After upgrading from VS 2005 solution, I noticed that the solution file was at the same level as the project files. Our standard is to have the solution file one level above.
Opening the solution file in 'Notepad' I see the following:
Add required relative path to each of the project path and save in correct location:
In my case to bring up one level 'BloombergPriceRequestService\'
SO project line(s) will look like this:
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BloombergPaydownService", "BloombergPaydownService\BloombergPaydownService.csproj", "{17DDDD3E-CD39-48B4-BE3F-71E550FCBBFC}"
EndProject
Global
Don't forget to delete your old solution file!
if I cut the sln file and paste it in
the root folder,it doesn't load any of
my projects
Do this anyway, and try to open the solution. It will tell you that some projects couldn't be loaded: ignore the warning.
Then, go ahead and delete all the projects from the solution. After this right click the solution and select Add => Existing project and browse to your project file. Repeat for all projects in your solution.
Sometimes, the solution file may contain more than 5 projects attached to it.
In that case, Creating the new solution and adding projects to that is cumbersome and takes more time.
You can just edit the solution file to load the projects correctly.
Steps to do
sdas
1. Open the solution file in notepad or any text editor.
2. update the path which is underlined and made bold.
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BloombergPaydownService", "BloombergPaydownService\BloombergPaydownService.csproj", "{17DDDD3E-CD39-48B4-BE3F-71E550FCBBFC}"
Save the file and open in Visual studio.
Editing the solution file is a hazardous way to do things and I found a better way. Just create a new solution and add copies of the folders containing the various projects (in their respective folders) to the project.
You need
to select solution in solution explorer
then to find button File -> SaveAs solution.sln as
Press it
There are two ways you can do it:
Simply delete the entire project and create the entire project again in the other folder ( which is not recommended).
Here are the steps to follow without missing any files.
a. Goto Source control explorer Create a new folder or Just move the solution to which you want to move the folder to.
b. Load the solution in your local and it will prompt a message saying that do you want to reload it from source control click yes.
c. Once we load the solution you will see that the project you have moved won’t be loaded (Since we moved to the other folder)
d. So now, Remove the project which was not loaded and then add it as an existing project
e. I am sure that if you have added nugetPackages they won’t get loaded.
f. Goto file explorer of the particular project open the .csproj file and try to check the packages location, Error condition, Project reference and Import and apart from them if there are any
Which are pointing to a directory.
g. The simplest way is just adding some nuget package and see what is the path generated by visual studio.
h. Once we change the locations they will be loaded in references
i. After adding references try to build the solution and it will throw some build errors because we moved the project from one folder to other.
j. Add the project reference wherever needed after moving the files
k. Now the build will be succeeded.

Resources