Visual Studio 2017 not updating references - visual-studio

I have a VS solution with three projects. When I make changes to the class library the references doesn't update and it keeps expecting the old namespaces and classes and results in error when building since it can't find the old namespace.
It also results in build errors if I try "using LC.Tools.API.Models" since it can't find the namespace and intellisense shows the old namespaces (LC.Tools.API.Model) with the old classes.
The solution contains two ASP.NET Core web projects and one ASP.NET Core Class Library. The class library is referenced as a project reference in the other two projects.
I've tried deleting the bin and obj folder on all projects, re added the references, rebuild, build, clean solution.. Is there a way I can fix this without having to recreate the projects?

Sometimes had similar issue in Visual Studio 2015 Update 3.
Solved it by right clicking on project in Solution Explorer and then choose the "Unload the project" option and after that right click on unloaded project again and choose "Reload the project".

Related

Namespace/Assembly errors in "Views" section in Visual Studio 2017

I have a .Net Core application that I used to develop on "back in the days of Visual Studio 2015". I have now moved on to Visual Studio 2017 and back to this project and I have a need to rename the project. I started following numerous guides online on how to rename a Visual Studio project, however none of them seems to support .Net Core and Visual Studio 2017. I believe it is important to mention that the only part of my project that complains about the namespace is the "Views" section, and it only seems to refer to files that have been created/edited recently.
After doing the following, I have still not found a solution:
Rename Solution in solution explorer.
Rename project in solution explorer.
Changing Assembly name in "Project" -> " Properties".
Changing Default namespace in "Project" -> " Properties".
Going to Program.cs and changing namespace using "Right-click" -> "Rename" -> "Rename all occurances".
Adding "#using " in _ViewImports.cshtml (complains about missing namespace here as well).
I am getting desperate as I feel like I have tried everything and nothing seems to works.
I have recently renamed my project from MobileFront to MSPFrontend and even if I change the "#using" statements inside my _ViewImports.cshtml back to MobileFront it still complains.
I am hoping that I am not the first one to encounter this tedious problem.
EDIT
I noticed the errors occured only when the files were open. I don't know if this is important to know of whether it has some importance for finding the solution.
I ended up downloading Microsoft.AspNetCore version 1.1.1 through NuGet. After doing that I created a completely new project and reopened my original project. That solved the problem. All of a sudden my project could find all namespaces and assemblies.

Find all references and Go to definition not working for a specific project in vs solution

In a VS 2013 solution with several projects I have added an existing project (dll) and referenced it in one of the other DLLs.
The problem is that when I use "Go to definition" for a class that is defined in this project the text from the metadata is displayed as if the text files of this dll are not in the solution.
Similar problem with "Find all references".
Language is the same C#.
Any ideas?
Problem solved.
When I added the reference of the existing project that I added in the solution I did not select it from the projects of the solution but browsed and select it from its output folder (debug or release).
That simple!

Upgrade to Visual Studio 2010 throws a build error

Recently upgraded to VS 2010 from 2008, the previously built solutions are throwing the following error.
Error 14 Encountered multiple versions of the assembly with GUID 'a5851ea0-2f9a-40b2-a73a-cd7db32f09c5'. Try pre-importing one of these assemblies
I tried re-installing VS 2010 and it didnot help. Any ideas?
Is it the VS 2010 application itself crashing, or does it not like your solution? Can you open VS 2010 by itself? If so, it sounds like it doesn't like some of your references in one or more of your projects. Check the project references. If that doesn't work, start removing projects until you find the offending one.
This may happen, if you copy-paste-renamed a project file to re-use its settings but didn't changed the project GUID of it. Also could be a project migration error, anyway you will have to manually edit the project file and remove the duplicate references if the project fails to load because of the error.
I had the same issue when migrating 2008 -> 2013.
It was caused that we use same linked AssemblyInfo.cs for all projects in solution.
And only for the assembly that used some COM objects (MSMQ) it seems that it starts looking on referenced assemblies GUID and two of them from our solution...
So when I provide individual AssemblyInfo.cs for projects with unique GUIDs it start working.
Hope this info will helpful.
Try to remove the references to the debug folder.
In Visual Studio right click on Project
Select Properties
Select the references tab.
Check to see if any of the references are from the obj\Debug folder and remove them.
See similar question here.

Why is Intellisense not working for one unit test project?

I have a Visual Studio 2008 solution which builds a C# class library (Project X) and C# Windows Application (Project Y).
In the unit test project for the C# class library (XTEST) , Intellisense works as expected and auto-completes the names of classes etc.
In the unit test project for the windows application (YTEST), Intellisense has stopped working and only auto-completes with the names of accessor classes, not the names of actual classes. Intellisense also reports lots of class names as being unknown/undefined. These appear in the error tab, but disappear after compilation.
Possibly relevant facts:
The projects all build correctly, and the tests run.
All programming is in C#, .Net 2.0 Framework, VS 2008 SP1.
It used to work...!
The Project Y was converted to VS 2010, then converted back to V20008 at one point. It's possible that other projects may have been converted and then converted back too.
Can any inspired reader point me in the right direction to fix the Intellisense in Project YTEST?
Answer
Turned out to be an issue with .cache files in the project obj directory. Deleting these fixed the problem.
For Visual Studio 2013, I couldn't find .ncb files in project folder. But deleting all the .cache files in obj\Debug folder worked. Didn't have to restart the VS.
Source: Grantly's comment.
try deleting the .ncb file in your project folder.
This will force intellisence to regenerate the symbol database.
what helped me was simply unloading and re-loading the project

What do you do about references when unloading a project in Visual Studio?

When you unload a project in Visual Studio, any referencing projects get warning triangles on their reference to the unloaded project. I've written myself a macro to do clever stuff (detect add/remove of project and transform any references from-to file/project dependency), but I can't believe that I'm not missing something much simpler. How can the unload function be any use if I have to go around manually changing references (and it breaks the 'personal solutions/shared projects' team development paradigm).
(This question is related to answers to this question about structuring large solutions in Visual Studio - some answers mentioned having solutions with lots of projects, but 'unloading' unused projects to improve performance.)
For my projects, I create an assemblies folder which the projects automatically copy into from a set location to which other projects copy builds.
Post-build for referenced assembly's project:
if not exist "C:\builds\Project1" md "C:\builds\Project1\"
copy "$(TargetDir)$(TargetName).*" "C:\builds\Project1\"
Pre-build for referencing projects:
if exist "c:\builds\Project1\" copy "c:\builds\Project1*.*" "$(ProjectDir)assemblies"
The project file points to its assemblies subfolder for references so even if the source projects are unloaded from the solution, the last-built assemblies will be used without the performance problems of having the whole project in memory while developing.
What are the advantages of having projects in the same solution if you use file references?
If your app.exe uses utils.dll and you change the code for utils.dll, then if it's in the same solution VS will notice the dependency and recompile both. If it's not in the solution you'll have to jump out, recompile utils.dll seperately, then jump back in and recompile app.exe.
This becomes either more or less important depending on how many other dll's your exe is referencing, and how often they change (in team environments shared dll's change often in my experience).
There is also the side effect that if you have 100 projects in VS it will take a long time to process them all just to figure out if they need recompiling or not.
Unloading projects is meant to be a temporary action so you can edit the actual project file as XML (text). If you want to completely remove a project from your solution, you should use the "Remove" menu option, which will take care of removing any references to that project.
One advantage to using project references is that it allows you to easily debug through the code. It also automatically ensures that you are using the correct configuration build (ie, if you are building in "Debug" mode it will use the Debug version of the assembly). That being said, you loose some determinisim about which version/build of the dependent project you will pick up - project references mean you always use the latest.
Yes, for Visual Studio to determine build dependencies it must be able to see and build all of the projects which would mean project references.
I've just had a eureka moment reading through MSDN doc on structuring solutions and projects.
What I hadn't noticed is that in a multi-project solution, the context menu in the Solution Explorer proposes a Project Dependencies popup. Here you can define the project dependencies manually, if you haven't defined them by project references between projects.
See here (MSDN link, so will self destruct after a few weeks)

Resources