C# [Design] lost .. only .designer left - c#

I did a huge plunder and accidentally lost my *.cs (Design file).. I just got the *.designer file left.
Can I go the other way around and create somehow a Design-File (*.cs) only with the .designer file or do I have to start over?

Please have a look in Recycle Bin and click restore. So you will get your file back in visual studio solution explorer with excluded status. Right click and include in project.
To avoid this type situations, use version controls in your project like:
TFS - Team Foundation Server
GIT
Visual Source Safe
SVN

Related

TFS Binding Invalid After Upgrading Project From VS2015 to VS2017

I began working on an .Net Core solution in VS 2015, which contains an ASP.Net Core project and a couple of .Net Core class libraries. The solution was under TFS source control.
I wanted to include some unit tests. Since .Net Core unit test project templates are not included with VS 2015, I decided to install VS 2017 and upgrade the solution. After upgrading, I was able to add a unit test project and everything compiles and runs normally.
When I first opened the solution after upgrading, though, I initially got an error about the solution being treated as though it was not under source control. Based on Google searches, I went into File -> Source Control -> Advanced -> Change Source Control and clicked "Bind" on each project. The three old projects link right up and show up as "Valid", while the solution file and the new unit test project show up as "Invalid". Unbinding, unloading, reloading, and rebinding the invalid project did not help. I can force the project to bind even though it is invalid (against Visual Studio's warnings), and after some tinkering, I can get the solution to check in, but when I get latest on another machine, the three original projects say "Not Available" and the unit test project is not visible.
Other symptoms: project.json is not found when I try to check in (I have to "undo" or "exclude" to check the solution in) and regardless of what I try, the invalid unit test project's folder shows up in the root folder of the directory tree (at the same level as "src" and "Backup") while the valid projects are in the "src" directory. I am inferring this is because the new solution types allow an .xproj file, while the old solutions required project.json, but I don't know what to do about it...
Any ideas on how to relink this to source control would be appreciated! I did not upgrade TFS server when I upgraded VS, but I don't directly have access to it, so hopefully this is not a requirement...
To fix the invalid binding in VS, you could try to follow below steps:
Click the “invalid” project in Solution Explorer.
Open “File | Source Control | Change Source Control”
Unbind the invalid project.
In Solution Explorer, Unload the project.
In Solution Explorer, Reload the project.
Also clear TFS and VS cache, delete the old workspace, create a new one, get all projects you need from TFS source control. Everything should be back on track.
Sledgehammer approach not normally needed, just Delete the contents from the following folder
C:\Users\<<Your Alias>>\AppData\Local\Microsoft\Team Foundation
Do not delete the rest unless necessary, fix the cause not the symptom.
My issue was that the project name had a period '.' in it. Removed it and the change source control Bind was Valid.
I tried all the solution above and none of them worked for me.
But I found a way to force add project. In Visual Studio :
Go to team explorer
Click on Home
Click on Source Control Explorer
Select the directory and click on "Add Items to Folder" (the icon is a file with a little green + in the top left corner)
Add your project files
... problem solved

I don't have the whole project from git

I am new to git. I made a repo and added a friend of mine to also contribute. He pushes the changes. Then i pull them and when i open solution explorer in vs 2015 it shows up only the files he was working on, but not mine. I searched in the file explorer and my files ARE there. How to view them from vs?
It's likely that you simply don't have your files included in the appropriate *.csproj file for your project. This actually sometimes happens to me as well. If you just right-click on the appropriate parent folder(s) in VS and select "add existing", that usually is all you need to do.
Post back if that doesn't fix the issue.

visual studio 2012 is not recognizing changes in code

For some reason, visual studio (2012) is not reading any changes in my code. It will recognize an error but, for example, if I get rid of something that makes a window appear, a window will still appear. I am also unable to debug my code (I get the 'symbols not loaded for this document' error). This has been going on for a few days.
I'm not quite sure what to do. I've cleared the visual studio cache but that didn't help. I've changed the startup project settings around but that doesn't change anything either. This is all from my local machine (no source/version control). Does anyone know why this is?
I fixed this by deleting the .suo (silverlight user options) file, as was suggested in the link below, thanks #amalgamate
http://www.kunal-chowdhury.com/2011/08/why-visual-studio-debugger-is-not.html
Try Build > Clean Solution then Build
This may not be your answer and I do not know silver light, but I have found the symbols not loaded error often when the solution file lost track of where a project file was, or when a project file lost track of a library. Maybe the file is missing, or maybe someone else on your team directed it else where etc.. To fix this in project explorer, right click on the solution or project and re-add the particular reference or project (using the add menu item). You may then have to remove the old project/ or reference. You will know the references and projects are bad because of the icon next to them in the project explorer. The bad links will also be listed in the output of your build with the bad links named.

Visual Studio 2008: Added Project not showing up in Solution Explorer

SOLVED! For people who are having the same problem this is what i did:
I moved the project away from where Visual Studio though it would be. This forces you to create a new project file there. I did. Then i restarted the program and now my project was visible. I now just moved the original project-files into the now visible folder.
I added an project to my solution but it doesn't show up next to all the other imported projects.
And since it doesn't i'm unable to delete it and try again.
However it can be seen if i right click the solution and go to "Startup Project", "Project Dependencies" or "Debug Source File".
I have searched the web for a while now but have yet to find someone with a similar sutiation, how do i solve this?
I imagine that this is because the files don't exist. Have you created the project on a network drive somewhere? Have you renamed or moved the folder after adding it to the solution?
Check the paths are right, then double check. Also check your version control to ensure someone hasn't wiped out your changes and left the .sln file intact.
You can edit the .sln directly I suspect to double-check the exact path it's looking for. Verify that path exists too.
Make sure the project you added was created in the same version of Visual Studio too.

C# - Visual Studio project build

I have the following problem.
I made an application in C# (using Visual Studio 2010). Everything worked fine.
Then I had to make some changes in a "main.cs". Did those... all fine again.
Then I had to make other changes in same file. Did those... cleaned the solution built it. The problem is that when I run/debug/anything the application I get the same result as I did before I made the changes. I even tried to break the code (called a random function that didn't exist, used wrong syntax), but the result was the same "Build successful" and the old version.
Is there some kind of cacheing mechanism or something? How do I get rid of this problem?
I added prints for the "compile" solution... I can't find the build property.
Try deleting the bin and obj directories in the Visual Studio project directory. The obj directory contains the temporary files used to create the binary while the bin directory contains the binaries for that project. In addition, check if there are any warnings being shown when you build your solution.
I was able to reproduce the same error i.e. build successfully even though the file has not been compiled. The Build Action of the file had not been set to Compile.
The correct Build Action for a code file (main.cs) would be Compile.
According the updated question the file properties does not have the compile option
The reason for this is that the file (main.cs) has not been included in the project, but the "Show all files" button is "on" in the Solution Explorer. The file has not been included in the project (hence not compiled) and the file icon is greyed out in Solution Explorer.
To include this file in the project, right click on add existing item to the project (see following image). In the subsequent dialog select the file (main.cs) and click on the add button.
This should solve your problem.
In future, it is best to keep the "Show All Files" button as "off" to avoid confusion.
Is it possible you have selected the build and run last successful version? Check out my answer to something similar here. If the changes you made broke something and you had checked the boxes and hit yes to the dialog boxes in my answer below then that's most likely the issue.
Cannot see changes I make when I run my application in Visual Studio
Make a backup of your solution.
Delete the .cs files from within the solution explorer. If your program compiles and runs, than you are linked to source folders and not actually using the one in your solution.
I doubt this is it, but worth a try. The other things that came to mind you have already eliminated out with the previous answers.

Categories