C# & Visual Studio : storage issue - visual-studio-2019

I have a problem with Visual Studio.
When I create a new project and start programming and in between I save, at some point when I want to run it, Visual Studio does not accept my new code. It always executes the old code although I have overwritten it.
I have already re-downloaded Visual Studio 2 times but that didn't help. I use Visual Studio Community 2019

Try using Ctrl+shift+B to build it, and then running with F5, instead of Ctrl+B or F7.

Related

Visual Studio for Mac 2022 - Hot Reload?

I am a fairly new to developing applications on Mac OS. I am using Visual Studio for Mac 2022 - Preview. I am all up to date and have created a ASP.NET MVC Web Application using .NET 6. I have started the debugger using the generated project. I make a change to the Index.cshtml file but that change fails to be reflected in the browser after saving the file. Any ideas if Hot Reload works in Visual Studio for Mac? I dont see any button to toggle the Hot Reload as all screenshots i have seen are for Windows Visual Studio. Any help would be appreciated as stopping and starting the debugger each time a change is made is very inconvenient. Thanks.
EDIT:
I have installed the Nuget Package
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
And then updated my Program.cs file as follows:
// Add services to the container.
builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();
My changes to .cshtml files still do not want to recompile after saving.
Any more help would be appreciated.
Visual Studio for Mac
Version: 17.0 Preview (17.0 build 5186)
Created a new Web Application (Model-View-Controller) project.
I got it to work on the latest preview version of Visual Studio 2022 for Mac. You will need to add the NuGet package, and also add the service to your builder in the program.cs file as an extra service:
builder.services.AddRazorPages().AddRazorRuntimecompilation();
https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-6.0&tabs=visual-studio#enable-runtime-compilation-for-all-environments
I don't know of any way to do it within Visual Studio, but if you navigate to the folder with your .csproj in Terminal, you can type
dotnet watch
and it will load your app. Then you can make changes within Visual Studio, save, and the browser will automatically reload. The only problem is since it's running from the command line, it won't hit breakpoints in your program (I don't know of any way to do so anyway).
As mentioned above, adding builder.Services.AddRazorPages().AddRazorRuntimeCompilation() works well, the only thing that you have to reload the page manually though, while your project is running.

Removing Visual Basic project Templates from Visual Studio 2019?

Is there a way to remove the Visual Studio project templates from showing up in Visual Studio 2019? I'm never going to use them and I've had multiple occurences where I accidentially created a new Visual Basic project instead of a C# project.
I've tried removing the physical files from Common7\IDE\ProjectTemplates and clearing the cache but the project templates keep showing up in the dialog.
to remove a template from Visual Studio you may use:
dotnet new --uninstall NAMEOFTEMPLATE.Template
to uninstall some project types (Visual Basic maybe) try Change Visual Studio Tool from Setup...

Microsoft Visual Studio Community 2019 CodeLens reference counter incorrect

I have a Windows Forms App with .Net Framework 4.8 and suddenly I realized that only a vertical line appears instead of the reference counter. Any idea how to fix it?
This applies to most of my solutions,but not all. I also noticed that if I reinstall Visual Studio it works after the first start, but once I close it and open it again the error comes back.
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE>devenv /resetuserdata" solved my problem.

cannot be opened. The project type is not supported by this installation

.cs project file
The project was created using Visual Studio 2010 and I am trying to open it in Visual Studio 2010 itself but still I am facing this problem.
I have opened this project in VS 2012 and worked for few days but it has created in Visual studio 2010. Is there anything which preserve the project details on local machine?
This is the specific project section in my solution file:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project Name", "Project Name\project name.csproj", "{48C1190E-7700-461B-ADCD-B5E0F1ECAD21}"
ProjectSection(ProjectDependencies) = postProject
{1F5440B3-9FD8-4FE2-B621-8697489ABDC4} = {1F5440B3-9FD8-4FE2-B621-8697489ABDC4}
EndProjectSection
EndProject
In Visual Studio it is possible to add Project Types, e.g. for creating an MSI, by installing an Add-On to the development machine. It appears that in the past this was done, and then that new Project Type was used to add a Project to the Solution. But now you are opening the Solution on a machine that does not have that new Project Type.
Look for the GUID of the missing Project Type, it should be part of the error you are getting. Then google "project type {the-guid}" to see which Add-On you need to install on your development machine.
It is also possible that a new Project Type was used in the Solution that simply can not work with VS 2010. In that case your options are either to keep using VS2012, or to start over with a new Solution in VS2010 and migrate the projects into it that are compatible (which may be a bit tricky or hard to do if VS2012 saved them).
Would it be too difficult to just recreate the project and include all the necessary files and references? Once the project was saved from VS 2012, the format may have broken compatibility with 2010. Sometimes this is fixable just by updating the version number in the project file, but I don't see it in your image.

migrate a asp.net mvc solution file from 2010 back to 2008

i did an upgrade and it caused lots of problems. unfortunately i didn't back it up. Is there anyway i can convert a 2010 solution file back into asp.net mvc 2008?
Make a backup of what's left of what you currently have before doing this ...
Create a new solution in Visual Studio 2008. Create new projects for the 2008 solution. Use the project menu or right-click the project and choose "Add Existing Items..." Choose all the code files .cs .vb, etc from your 2010 structure and include them in the 2008 structure.
Basically you're copying all the code back into a 2008 structure with the 2008 formatted project and solution files. The code shouldn't be substantially changed beyond repair. You might have to manually address some issues in the converted code but once you know what they are it will be a repetitive process more than anything.
If you are writing code of any importance you should be using a version control system like as SVN. I haven't tried Visual Studio 2010 yet, but can tell you from experience that the differences between 2005 and 2008 are laughably small. You can down convert a 2008 solution file by manually changing the first two lines from:
Microsoft Visual Studio Solution File, Format Version 10.00
Visual Studio 2008
to
Microsoft Visual Studio Solution File, Format Version 9.00
Visual Studio 2005
the project files are fairly trivial as well with the product tag changing from:
9.0.21022
to
8.0.50727
Please note the changes I have listed for project files may not be 100% accurate and I have not tested for differences between service pack releases. However, creating a new project in an earlier version of Visual studio, making a copy and then doing an upgrade should allow you to run a diff and provide a better answer than what is currently accepted.

Resources