Problems with renaming .cs properties in the solution explorer - c#

I am having trouble renaming my file from T1_Khan_Saad to P1_Khan_Saad. There is no option to rename when I right click in the solution explorer.

According to the file icon in your screenshot, this is a linked file (note the little arrow at the lower right-hand corner). Visual Studio cannot directly rename linked files (which makes sense - they might be referenced by other projects as well).
What you can do is:
Remove the file from your project.
Rename it at its physical location using Windows explorer.
Re-link it to your project.
There's a uservoice entry for enabling this feature in Visual Studio:
Allow renamed linked files in solution explorer

Related

Files pulled from Git result excluded from the project

I need your help with Visual Studio and Git. I and a friend of mine are working on a simple project written in c#. We share the project with git (the code is on GitHub) but there's something wrong: when I pull his new files (or he pulls mine) the files result excluded from the project. I can see them in the project folder, but not in the Visual Studio Solution Explorer. To see them I have to click on the "Show All Files" at the top of the solution explorer and then they appear, but, as I said, they result excluded (with the dotted border). See the image here below:
This is strange. We have always worked with Git on other platforms (Android Studio, Eclipse, xCode) and this is the first time we encounter this problem. How can we solve it? Thank you in advance,
Sometime you have to add the files manually. Click on the folder in VS and "Add existing item" if your missing files are on the disk.
Equivalently, if some of the source files do not show in the Solution Explorer but do in fact exist in the project folder you can simply drag those files into the Solution Explorer. Following worked for me with VS 2015.
Right click on the project and click on "Open Folder in File Explorer"
Drag the missing file from the File Explorer to the Solution Explorer and drop in the place you want it to be and save solution.
Now it should appear in the project Solution Explorer.

Should I put Settings.Designer.cs under Version Control?

Visual Studio autogenerates this file. Searching for info on it tells me to never edit this file. Fine, but do I need to store it in my VCS or can VS auto-regenerate it whenever needed?
I believe that Settings.Designer.cs and other similar files should be under version control.
I ran into problems using the advice of the other answer here on this question.
Settings.Designer.cs is only modified if changes are made to Settings.settings, and it is auto generated by Visual studio, but not by build tools.
When I removed Settings.Designer.cs I ran into issues where Visual Studio wasn't auto-generating the file when expected, and I had to do several rebuilds/reloads of my project until finally it randomly appeared, and I'm not sure what actually triggered it.
Also I was having issues on our TeamCity build server because the build tools there were not generating the file, so I had build failures saying it was unable to find Settings.Designer.cs
I found a good rule of thumb in this answer on another question, that basically if the build system modifies the file, then don't put it in source control, but if it is only modified when you make changes to another file and is generated by visual studio, then it probably should be in version control.
Also, Visual Studio 2017 can automatically create a Git repo with a .gitignore file when creating a new project, and by default all of the *.Designer.cs files are included in the Git repo.
The problem with adding these items to version control is, that different version of visual-studio, or perhaps other environments may generate these files in different ways. This sometimes leads to irritating conflicting errors on build servers ect.
VS can auto generate this file.
After reading this answer, I went ahead and deleted the Properties/Settings.Designer.cs but got an error when building the project that "the file was missing". My project still had the references to it. So it is important that you also remove the references from the Project.

Linking a .chm file to a .dll in Visual Studio 2010 C# Project

I have just got hold of the following binaries because
I want a nice way to parse CSV files in my Visual Studio 2010 C# project.
The binaries file includes a .dll, .xml and .chm file.
I linked the .dll into my project using the Add Reference option in the Project menu. Visual Studio recognises the class and it comes up as an option with IntelliSense, however, I cannot see the documentation in the .xml file within Visual Studio.
How do I see the documentation?
To see the documentation please double-click on a PC having Windows installed (and this is the only way at this stage for you). But one step you have to do first:
When you unzip the CHM only the TOC is showing, the right information panel is blank (file not found).
Microsoft is trying to protect you from CHM files (since they can execute stuff). Using the Windows built-in Zip support it makes sense that Windows security may try to stop you viewing the CHM from a ZIP.
After unzipping the CHM you need to right-click it, select properties and click the unblock button.

I can't see the folders I created in my project

I have been working on a project in C# in Microsoft Visual Studio 2012. Since I have a lot of C# files I decided to put them in a few folders based on their type. For example an interfaces folder and an enumerations folder.
Now when I open my project I can't see any of my folders and all of my C# files are not in folders. I can't open the files because it says that the directory has changed or has been deleted. I am adding a photo so you will be able to see what happened to me.
You should've created the folders and moved the files inside the VS Solution explorer, then everything is tracked automatically.
The easiest way to fix this is to enable "Show all files" at the top of the solution explorer, refresh the view to make sure you can see everything
Then right-click the slightly grayed out folders and choose "Include in project"
Once that's done, delete the "Broken" old files.
Follow the steps to add the files back to the solution
From the Project menu toggle on "Show All Files"
Now you should see the files/folders in Solution Explorer.
Select those you want to include
right click and choose "Include in Project"
after include all files delete the broken file links
Sometimes you have to click "Refresh" in the solution explorer first. Then you will be able to see hidden files, when clicking "Show all files" and you will be able to "include them in project".
sometimes Visual Studio file tree lacks your latest update to solution explorer
so, the solution is to just right click on your solution and select "Sync Namespaces"

Visual Studio Modifications to a Project not Updating the .exe File in \bin

I am quite new to Visual Studio (Express). I made a project and then put a shortcut on my Desktop to the .exe file. Later I made some changes to the project which are all visible when I run the project in Visual Studio using CTRL + F5. However, the .exe file that is pointed to by my Desktop shortcut still runs the old version.
Any advice is appreciated.
Regards.
by rightclicking on your project in solution explorer, going to properties and then going to the build tab you can choose your output path. bin\Debug\ is the default which is probably where your newly built .exe is going
You may need to use the "Rebuild" action instead of "Build". Sometimes .NET compiler gets confused what has changed - "Rebuild forces a recompile of the solution instead of just the "changed" files.
There can be many reasons for the issue. What I did was removing the .exe files present in the /bin/Debug directory. The rebuild will automatically generate the .exe file again.

Categories

Resources