Visual Studio builds are reverting code to pre-correction states - visual-studio

So, new to .NET Core and going slow. Followed a standard tutorial for ASP.NET Core MVC app using Entity Framework to connect to MSSQLLocalDB - this went well.
Converted the application to connect to MySql, and went equally well,
Changed the name of a table on MySql to Interests from Interest, and after a bit of fiddling around this to was put to bed, that is it was working as expected.
Went to run the application today and I get:
There were Build Errors Would you like to continue and run the last successfull build.
Code has reverted to Interest, from Interests in several places in Obj files,
for instance "Create.cshtml.g.cs"
Corrected the code and went to run, the same build error pops up, and all corrections are undone.
I make the changes again, save the files, exit VS, reload, the changes are as they should be, run and it reverts all changes, failing again.
I thought this might be some sort of cache issue so deleted the obj folder, again corrected the entries, but again run the build and the corrections reverted!

I solved this issue on my machine by changing the cshtml file properties. Right click the chstml file in the Solution Explorer window, click on Properties in the context menu.Then in the Properties window, change the "Copy to Output Directory" to "Copy if newer". Then make sure "Build Action" is set to "Content".

Related

Visual Studio 2015 no longer generates executable

I had a Windows Forms application that needed some UI and code changes changes made to it. I made the proper changes (mainly deleting a few controls and moving some code). Oddly after the changes were made, I would rebuild run, and despite the changes, the changes being saved, and builds being made multiple times,the application would always run as if the changes were never made.
I tried to Build -> Clean Solution a few times, with no avail. I decided to try manually deleting the bin and obj folders and rebuild. However, after closing the solution, deleting those folders, I tried to build again and get the following error:
OutputPath and AssemblyName are set correctly as far as I'm aware. This only affects Debug, Release runs fine (sort of) and even in debug XML and *.vshost files are created, but not the executable. I've tried restarting VS a few times to no avail. What in the world did I do and how do I fix it?
EDIT After right clicking on the solution and doing a batch-build on all projects in the solution, things started working. I still have no idea what happened, so if anyone has any theories feel free to comment.
Does the Output window provide any details about where the .exe was created?
You may need to increase the verbosity of the logging. To do so, go to the Options dialog (Tools > Options) and open "Projects and Solutions" > "Build and Run." Change the "MSBuild project build output verbosity" and recompile.

SSIS script task "The binary code for the script is not found"

This problem is very similiar to those:
"The binary code for the script is not found" and
The binary code for the script is not found” ssis
I have an SSIS project with multiple script files. SSIS claims that one of them has no binary even though there should be. There are no code errors, and I can build it properly. I suspect it's a VS bug because this problem appears and disappears randomly. What I mean by that is that this script is working fine, I open it to see the contents, close and suddenly this error happens! So I open it like 20 times, and it (without me doing anything) repairs itself! Any ideas on how to make it work better? It seems (though I can't confirm with 100% certainty) that this problem happens when you save the SSIS script (as in use ctrl+s) instead of simply exiting from the VS.
Things that I have tried that sometimes work:
Restarting Visual studio, opening the script without doing anything, closing it
Adding a small change to the code, exiting
Removing and adding breakpoints
Going on my knees in the direction of Redmond, Washington, and chanting the names of M$ presidents while opening and closing windows in the building to the rhythm of the windows starting sound
Randomly closing and opening the project, as well as going through items in the script component menu
Things that don't seem to work: rebuilding project, cleaning project, you know the standard stuff
I've found a solution that OFTEN works. Notice the usage of often.
1) Try restarting your computer.
2) If it doesn't work go to your system temp files directory, and find the location of SSIS temp projects (you can also open the script, right click on C# project, explore in windows explorer). Delete the project. (Make copies before deleting just in case). Start Visual studio, and once again edit script, close, hope it works. DON'T SAVE THE SCRIPT PROJECT BEFORE CLOSING! JUST CLOSE!
Note that for the second step, you can also try using a cleaning tool, like CCleaner of similar.
In my case, I did some idiotic changes to main package solution config manager and tried changing the "Target SERVER Version". That wiped out all the scripts project from each packages. Then I came to know that it is auto-generation everytime we open. That means each package is storing script project within it. But now I don't know why its not generating while pressing on "Edit Script button" (really pissed!)
Thank for suggestion. In my case, I did some idiotic changes to main package solution config manager and tried changing the "Target SERVER Version". That wiped out all the scripts project from each packages. Then I came to know that it is auto-generation everytime we open. That means each package is storing script project within it. But now I don't know why its not generating while pressing on "Edit Script button" (really pissed!)
"Lucky I am" . got an fix! Each package file was internally not linked with their Script.cs. So I opened each package file in Notepad++ and found Script.cs content within. I recreated scripts.cs in each package (steps) and pasted the content from notepad++. And it worked!!!

How to clear Visual Studio workspace

I have a workspace in VS2015 (same problem in 2013) that I'm trying to completely remove and start fresh with a copy from the server. To clarify, I want none of the files or changes that currently exist and I want to start completely fresh with the server copy of all files. I don't know how to correctly do this, however. I've deleted the workspace, the actual files that the workspace pointed to, and I've cleared the cache locations below, but VS still shows that the workspace exists and won't fix itself. In fact, it still shows the mapping even though I've triple-checked that it's deleted.
I'd like to avoid using devenv /reset since I'm pretty customized and I don't want to fix all of it, but I'll do it if it's unavoidable. How can I accomplish this?
Locations cleared/deleted:
%LocalAppData%\Temp\<all VS files/folders>
%LocalAppData%\Microsoft\Team Foundation
%LocalAppData%\Microsoft\VisualStudio\<version>\ComponentModelCache
On the window where you can get a specific change set from TFS, get the changeset with id "1". This is the situation just before the project was created - empty!
Right mouse om project node in solution explorer
Source Control > Get specific version
Version type "change set"
Input change number "1" (without quotes)
Click "Get"

This Breakpoint Will Not Currently Be Hit, The Source Code is Different from the Original (even after cleaning/rebuilding)

.NET 4, console application. The project is set to 'Debug' mode. The breakpoint being set is in the primary/startup project. I have right-clicked -> Clean, and right-clicked -> rebuild, both on the Solution and project levels.
Following the instructions in this SO question, I have confirmed that my "Build and Run" options are set to 'prompt' for both 'When projects are out of date' and 'when build or deployment errors occur', and I am NOT getting a prompt when I F5 to build/run.
Also, the 'save all changes' under 'before building' is also selected (plus I manually saved them myself).
I monitored the output window of the application, see this line:
'MyApplication.exe': (Managed (v4.0.30319)): Loaded 'C:\exepath' Symbols Loaded.
I restarted the VS2010 instance. I restarted all open VS2010 instances (of other projects). I've even gone through a reboot.
However, the breakpoint I am setting in the startup project is a hollow-red circle, with the notice that 'This breakpoint will not currently be hit, The source code is different from the original', and, in fact, is never hit.
So, this is really 2 questions:
1) How do I fix this problem so I can properly breakpoint
2) When I see this, does that mean my code is executing from an older build?
I've had this problem once myself but that was on a vsto addin. In that case there were left over intermediate files under the users/appdata directories that were actually loaded instead of my app.
There is this blog article that has a whole load of possible reasons for this error and then a whole bunch more in the comments from other users
This can also happen if you have a solution with multiple projects, and have the wrong project selected as your startup project in VS2010 and VS2012.
Now, obviously, I wouldn't expect debugging to work if I have the wrong startup project selected -- the debugger is attaching itself to the wrong process!
But this error message (in my case) was terribly misleading. It made me think something else was wrong. I tried a bunch of solutions in this thread (nuking various /bin and output directories) when really it was something very simple (wrong startup process).
If you are using vb, check that you are building the project for the active solution configuration (Build, Configuration Manager..., Column under Build is checked. Also check the project properties, Compile tab, Advanced Compile Options, and Generate debug info is set to Full. Sorry I can't tell you where this may be in C#.
The only other time I've seen this is when two projects in the solution are referencing the same dll but they are referencing from different sources. One from a project reference and another from a file reference for example. If the "copy local" option is true, there would be the potential of overwriting the dll with an older version of the same dll.
My solution might help people who have signed the assembly.
After lot of head scratching for the past two days, I was able to resolve the same issue by doing the following simple steps:
Go to your Visual Studio project properties.
Go to the "Signing" tab.
Uncheck "Delay sign only" option if it is checked.
Now run your project and it should work.For me it did work.
In my case was this same problem (“The breakpoint will not currently be hit. The source code is different from the original version.”) caused by fact, that I tried add breakpoint to declaration:
DateTime dt;
bool b = DateTime.TryParse(null, out dt);
(first line of code)
So I assume that message is "universal" and may have many different causes.
This can happen if your system clock was changed since the last compile. Your PDB file will be different date than the one your are trying to debug. Delete the PDB files in the project and recompile.
I experienced the problem when Project > Properties > Web did not have "Enable Edit and Continue" selected. After enabling this feature the issue was corrected.
It is important to note that under Tools > Options > Debugging > Edit and Continue "Enable Edit and Continue" was selected, but it was not enabled for this project.
Just go to Tools / Import and Export Settings
Choose reset all settings then click Next
No, just resetl settings, ovewriting my current settings then click next
Choose your current language, por example C#. then click Finish
If you have multiple solutions open, try simply closing all Visual Studio instances and restarting only the instance you need.
In my experience this has happened when two branches of nearly identical code are open in different instances.
doing a "clean solution" from VS Build Menu might help you.
I had to go over all those steps to fix the issue on my computer.
Make sure that debug = "true" on your web.config
Clean and rebuild all projects
Delete every file inside the bin folder of all projects
Close and open Visual Studio, rebuild, and run the project again.
Go to your solution folder -> obj -> Debug - > delete the .dll file and build the solution again.

visual studio keeps asking to save project file as

I am using VS 2010 and recently I moved some files around and changed paths etc.
The solution still compiles correctly and all files are able to be loaded/compiled without error however just about every time I go to compile after a change it gives me the save as dialog and asks me to save one of the projects, if I try to give it a new name or something the dialog does not exist nothing I do can make it exit apart from pressing cancel.
If I do a build straight after cancelling it works fine and I'm not presented with the save as dialog. I have verified that the project file is not read only.
Any ideas as to whats going on here.
The solution is stored in TFS 2008
You need to do 2 things
1- remove the read-only tick from the project folder
2- when a save-as window prompts at build, just overwrite the project
next time you build, the window won't pop up
You need to run VS as administrator. (right click on VS Icon- Run as administrator)
I solved the issue. When I try to save as this time it gives the error that file is being used by another process. Google Sync prevents to save so it opens save as dialog.
You should put your project under a folder not sync while working.
Are the bindings in TFS set up correctly with the new location? TFS will mark files as read only unless they get checked in. It might have been marked as such before you moved everything around, and now, isn't being checked out properly.
Also, try closing sync. files tools like google backup and sync.

Resources