Can't rename Visual Studio 2010 Project - c#

I have a Visual Studio 2010 Solution, that is also under source control (TFS 2010). Usually, I have no problem renaming a sub-project; just right-click, rename, and life is good!
However, I now have one project that I'm trying to rename, but whenever i right-click, type in a new name, and then hit enter, it goes right back to the old name!
I must be losing my mind here!

You probably already have a file with the name you are trying to use on the filesystem though not as part of the solution/project.
Use the windows explorer to find and delete this file and you should be good to go.

In the end it seemed like a TFS issue. THere was a lingering shelveset that was mapped to the project that wouldn't allow me to modify it at all. Once I was able to get my TFS admin to make the necessary changes, all was well!

Just try to do Reset Settings
The command "devenv /resetsettings" will restore Visual Studio back to its original factory state. If you have previously saved your settings from option 1 above, you can pass them as a parameter: "devenv /resetsettings ".
Or else if you have saved any previous settings try to import by this path "Tools" > "Import and Export Settings…" and your problem get resolved.
If this is v1 sorry you can't rename it as it is mentioned here http://social.msdn.microsoft.com/forums/en-US/tfsgeneral/thread/9e50138e-46f2-4f7f-ba09-e5624d30250b/

I tried to go offline from TFS but it gave no results =(
So, then I tried to delete 'SolutionName.suo' file and it made the trick! I was able to rename my project. Buggy VS 2010 =(

Related

One file keeps opening in visual studio IDE

I'm using Visual Studio 2010
In one solution I have A.XAML file and it keeps opening every time I start solution. It also opens at some random time - I have no exact explanation.
It's very annoying. Why would VS open specific file by itself?
Does it open even when you create a new project? How about locating the file and renaming it does it help the problem? Also, have you tried to backup and remove the content of C:\Users\<your_username>\AppData\Local\Microsoft\VisualStudio\?
Update 1 based on comments:
So when you renamed all your A.XAML to B.XAML, do you get the A.XAML appearing or do you get a B.XAML file? Do you have many instances of the A.XAML file on your computer? If there are many, rename them differently so that you can subsequently identify the guilty one. Have you tried to 'Repair' VisualStudio through 'Add Remove Program' in Control Panel? Can you locate the A.XAML string in Regedit.exe? I think it could be useful if you would create a dummy project and ask a colleague or, friend to open it on their computer? (It would be helpful to get have a sample of that dummy project in order to troubleshoot whether it is the Project or, the IDE or, the OS which is the guilty party)
Update 2 based on further comments:
Recreating the .SUO file of the project fixed the problem. For example, renaming the .SUO file to .BAK and re-opening the project in Visual Studio.
What worked for me was running Visual Studio installer and choosing the repair option.
I had a whole solution that always opened a few seconds after I open any other solution. I didn't want to delete the solution so I thought I should try repairing Visual Studio (using VS2019). Haven't had any issue since.
Seems like an 'intense' option but it was what worked.

Visual Studio C# IntelliSense not automatically displaying

Just recently, my Visual Studio 2010 stopped displaying IntelliSense suggestions automatically while I am typing. I can still press ctrl+space to get it to work, but it doesn't automatically show a list of suggestions like it used to. I have already tried disabling all my extensions, restarting VS and the computer, and I have checked all the appropriate settings (Options -> Text Editor -> C# -> IntelliSense) to make sure that it is set to offer suggestions after a character is typed.
Has anyone seen this behavior before? Does anyone have any other suggestions for how I can get IntelliSense to go back to the way things were before? If not, I might just have to do a fresh reinstall of VS...
In prose, in case you can't see the above image:
Open Tools > Options > Text Editor. If you're only having this issue with one language, find that language; if it's for everything, click "All Languages". Right at the top, there'll be a few options labeled "Auto list members", "Hide advanced members", and "Parameter information". Make sure all of those are enabled (though the second may be disabled; if so, ignore it).
I have found that at times even verifying the settings under Options --> Statement Completion (the answer above) doesn't work. In this case, saving and restarting Visual Studio will re-enable Intellisense.
Finally, this link has a list of other ways to troubleshoot Intellisense, broken down by language (for more specific errors).
http://msdn.microsoft.com/en-us/library/vstudio/ecfczya1(v=vs.100).aspx
I'll start off my noting that this hasn't happened since I upgraded my RAM. I was at 4GB and would often have multiple instances of VS open along with SSMS. I have since gone to 8GB and then 16GB.
Here's the steps I go through when I lose intellisense.
If only one file/window appears to be affected, close/reopen that file. If that doesn't work, try below.
In Visual Studio:
Click Tools->Options->Text Editor->All Languages->General
Uncheck "Auto list members"
Uncheck "Parameter information"
Check "Auto list members" (yes, the one you just unchecked)
Check "Parameter information" (again, the one you just unchecked)
Click OK
If this doesn't work, here's a few more steps to try:
Close all VS documents and reopen
If still not working, close/reopen solution
If still not working, restart VS.
For C++ projects:
MSDN has a few things to try: MSDN suggestions
The corrupt .ncb file seems most likely.
From MSDN:
Close the solution.
Delete the .ncb file.
Reopen the solution. (This creates a new .ncb file.)
Notes:
This issue does not appear to be specific to C# as C++ and VB users
report the same issue
Tested in VS 2013/2015
Steps to fix are:
Tools
Import and Export Settings
Reset all settings
Back up your config
Select your environment settings and finish
I also faced the same issue but in VS2013.
I did the below way to fix, It was worked fine.
Close all the opened Visual studio instance.
Then, go to "Developer command prompt" from visual studio tools,
Type it as devenv.exe /resetuserdata
Restart the machine, Open the Visual studio then It will ask you to choose the development settings from initial onwards, thereafter open any solution/project. You'll be amazed.
Hope, it might helps you :)
Deleted the .suo file in solution folder to solve the problem.
Sometimes i've found Intellisense to be slow. Hit the . and wait for a minute and see if it appears after a delay. If so, then I believe there may be a cache that can be deleted to get it to rescan.
I hit this today after the following sequence:
Added a new class to my project.
Closed Visual Studio, but accidentally selected No when it asked if I wanted to save changes.
Reopened Visual Studio, and found that it reopened the new file automatically but without my previous changes (as expected). However, IntelliSense was no longer working in the new file.
The problem was in addition to not saving changes to the new file, it didn't save changes to the project, so after reopening Visual Studio the file was not part of the project. The Show All Files command in Solution Explorer, or Add → Existing Item..., resolved the problem.
I had the file excluded from the project so i was not able to debug and have intellisense on that file.
Including the file back into the project solved my problem! :)
A new cause for this in the .net core era is having a project loaded for an unsupported .net core version. For instance if you loaded a project from GitHub that was set to use:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
But you only have 2.1 installed or find yourself using Visual Studio 2017 then the compiler wont be able to find the SDK code and thus provide intellisense.
The solution in that case might be to right click on your project and select Edit MyProject.csproj from the context menu and change the target framework as necessary:
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
This assumes whatever project you loaded can actually be run under a lesser target framework.
I simply closed all pages of visual studio and reopened ..it worked.
Deleting the .vs folder in the solution solved my issue. You have to exit from Visual Studio and then delete the .vs folder and start Visual Studio again.
Closed all my VS windows
Started the Visual Studio Installer and clicked 'Modify'.
Under 'Individual components' > 'Code Tools' > Deselected NuGet package manager and re-selected it.
After modifying and restarting VS, IntelliSense was working correctly again.
Found my answer on https://developercommunity.visualstudio.com/content/problem/130597/unity-intellisense-not-working-after-creating-new-1.html
[Tools -> Options -> Text Editor -> All Languages -> CodeLens]
Check if check box "Enable CodeLens" is checked
I have just come to about this problem while installing one of the extensions and its file was deleted by my anti virus so I just disabled my anti virus and reinstalled visual studio. Suggestions are working properly without any changes made after installation.
At the bottommost right look at the blue line where Ln, Col, Spaces, UTF, CRLF,..... here the language is specified.
Check that your language and the language specified there are the same.
In my case, it was Django Python while I was trying to use HTML.
This may be due to the solution configuration changed to Release Mode instead of debug. Right click on solution -> Properties -> Configuration Properties -> Set Configuration To Debug if it is in Release.

ClickOnce - Cannot publish because a project failed to build

When I try to publish my (WPF, C#) application, I get these errors:
Cannot publish because a project failed to build.
Could not find file 'obj\x86\Debug\MyAPP.exe'
I get these errors no matter where from I publish: publish wizard, build menu or right click on project - publish.
First it was working ok, but I did the following:
I changed the date om my computer to 10/10/2013, I was trying something else. I forgot this and I click build. Then I set the proper date on computer. After that I get these errors.
Also every time I click run Visual Studio builds project whether there are changes in project.
I also noticed that when I set the date after 10/10/2013 it works ok.
I am guessing that I am looking for some settings in my project where this date of build is set.
I tried build, rebuild, clean solution.
This is a problem with Visual Studio that can occur when you have add-ins installed. Instead of using the Publish button in the Publish tab, use Build/Publish from the menu on the top of Visual Studio.
If you use the Publish button, it runs through the add-ins before doing the build (or something like that). If you use Build from the menu instead, it goes straight to msbuild and ignores any add-ins you have installed.
If you have DevExpress installed and are still having problems, check out this article:
http://www.devexpress.com/Support/Center/p/Q260132.aspx
With the date back to normal, close VS and try deleting your *.suo files next to the *.sln files and then reopen the solution
I'm not sure exactly how your development machine can get fouled up this way, but this started happening for several developers in our group too.
After researching it, it appears that the built in build/publish script that Visual Studio (2010 in our case) uses has a flaw in the order that it does things. Most importantly it runs a cleanup on the OBJ directory deleting the target EXE file before the publish step can grab it.
The solution
This is somewhat of a hacky workaround, but it solved the problem for me.
The fix is to copy the file back to the /obj/ folder from the /bin/ folder right before the publish step. Unfortunately there is no way that I know to specify a BeforePublish event through the IDE, so you will have to edit the .vbproj file in a text editor.
Add the following section just before the final </project> tag.
<Target Name="BeforePublish">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(IntermediateOutputPath)" />
</Target>
I solved my problem. The problem was the "Modified" time of some files. I used the program Timestamp to fix it.
As I said in my question, the problem was that I build the solution and the date was in the future. Because of that, every time I pressed F5 Visual Studio was building the whole solution again and Publish ClickOnce wasn't working.
If nothing else works, try this :
Set your date to the proper date.
With VS closed, delete all the bin and obj folders of your solution.
Create a new empty solution.
Add your existing projects to the solution.
Add back the needed references.
Rebuild to make sure you didn't miss anything.
Publish.
If you want, you can also just try step 1, 2, 6, 7 before, if you don't feel like making a new solution.
Just create a new ClickOnce manifest certificate, and it will work again.
I have sometimes had problems with an ASP.NET project publishing, because the publish wizard couldn't delete files in the directory it was trying to publish the files to.
Try clearing out those file manually before publishing. Also check the output window; it will sometimes give you some hints as to why the publish failed.
I just ran into the problem today. In my particular case, it was caused by Microsoft Windows Update, Microsoft Security Advisory 2661254 (concerning minimum certificate key length).
I uninstalled that update and publish began working as it always had. This is only a temporary work around and means you should probably regenerate your keys/certificates.
I've had this error when I'd been swapping git branches. A Rebuild All fixed this for me.
In my case, the problem arise when I added the following section in .csproj File:
<Target Name="AfterBuild">
</Target>
Closing and Opening Visual Studio worked for me.

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.

Visual C# 2008 Express doesn't give me any options for break points besides creating/deleting them

I'm not sure why this is, but all I get is a 'create breakpoint' and 'delete breakpoint'. There is no option for a 'when hit' or something else like that.
Any ideas why?
This functionality is not provided in the Express edition of Visual Studio. You can have a look here for details.
I'm not quite sure where BP info is stored, but this did the trick for me (C# 2010 Express):
close the IDE
delete the *.vshost.exe (see EXE/DLL output folder)
delete the *.SUO file
now re-open the IDE and load the project again.
Notes:
The *.vshost.exe might need to be terminated the hard way before you can delete it.
Deleting the *.SUO file also takes away some of the IDE project group settings, such as files opened, project tree folding, etc.

Categories