I'm running Visual Studio 2017 on Windows 11 Pro. I have a large-ish Winforms project. Recently I started having trouble adding new files to the project.
I'll try to add a new class by right-clicking in Solution Explorer. The Add New Item form pops up, I'll enter the class name, click Add and I'll get an error pop up that just says
"The system cannot find message text for message number 0x%1 in the message file for %2."
The new file does not get added. I close the Add New Item form. Now my Project file is empty. Something happened during the error to delete the contents of my project file. I'm using Git and my client shows that everything was deleted so I just undo the changes in the project file so I haven't lost anything yet.
I'll try again and usually I can add a file. Then at some point I'll go through this again. I've rebooted my machine many times.
Anyone have any ideas what is happening?
The same error message also frequently appears in my VS 2019. Generally it happened during check in dan publishing proess. The workaround I did was to restart the application (VS 2019), and magicaly it solved my problem. But it doesn't prevent the issue not to happen again in the future.
I have a relatively new installation of VS 2019, running on a relatively new PC with Windows 11 (all about 2 months old). I also have Resharper and Web Compliler installed. All are up to date.
Within the last two weeks VS has begun having intermittent problems saving the csproj files when I add a new file to the project, or rename an existing file. It opens a file save dialog prompting me to save the csproj file, but when I click save, it then presents an alert dialog stating:
An error occurred saving the project file X.csproj
Clicking OK then returns me to the file save dialog. If I continue to click Save and then OK the alert, after a few tries, it usually saves eventually. Though sometimes it goes on so long that I abandon it.
Sometimes I can add/rename a file and it doesn't exhibit this problem at all.
I've noticed that when it's prompting me to save the csproj file, the existing file doesn't actually exist, so it doesn't appear to be a permissions issue, as the original file has seemingly disapppeared.
In addition to this, sometimes, if I try to duplicate a file in the project by clicking the file in the Solution Explorer, then hitting Ctrl+C then Ctrl+V, it gives me an empty error dialog (no error text), and the file doesn't duplicate. Again, persisting usually works eventually.
I've tried this on multiple Solutions, and I've tried suspending Resharper, but the problem remains.
I've tried repairing the VS installation, but that didn't work either.
I'm working on a project in Visual Studio 2012, that's hosted on TFS.Any way, I don't know if it's due to lack of sleep or sheer carelessness, when trying to move one large function body from one file to another, I copied the declaration to the new file, but forgot to copy the body and then erased the body from the old one, clicked save by reflex and closed the first .cpp file, so when I pasted it in the second one, to my surprised I pasted the declaration and not the definition.Undo pending changes would only undo the 'Add' alltogether.Is there ANY way to retrieve the lost source or should I start rewriting it ASAP?Because I spend quite a while writing it.
View the history of the file. Right click it >> Source Control >> View History, as below:
This obviously assumes you've checked it in at some point.
Under Visual Studio you have several levels of Copy / Paste, so you could have retrieved it by pressing CtrlAltIns (if I remember well).
If you still haven't closed Visual Studio, it might still be in your Copy / Paste ring, it might be worth giving it a try.
Otherwise, you can always rollback to a previous check-in state in your TFS server (if you checked in the code you want before you deleted it).
First, check-in your current state to the server. Then rollback to the previous version that had your code (right click your solution, then Source Control -> Get Specific Version). Now copy your code in a side editor. Re-go to the latest version (Get latest Version... on your solution). Now re-paste your code at the right place and you're done.
If CTRL+Z doesn't work inside VS, go to the empty folder of the deleted files and try CTRL+Z there. Has worked for me several times.
I am opening files from a server ASP.net and the VB codebehind files, and my visual studio is not working correctly, Intellisense is dead and if i right click the "Go to defenition" option is disabled. These files are not part of a solution.
This is strange though because it was working properly yesterday. If I create a new project the intellisense works great, yet opening this single file it fails.
I have tried to re enable intellisense by resetting visual studio, I tried editing the text editor settings so that Auto list members and Parameter information are both checked. I even tried installing ReSharper and nothing worked. I have rebooted twice and even tried copying the file to a local drive to work on yet nothing.
Does anyone know why this is happening and what I could do to solve the problem? Im working on a rather complex problem and intellisense would make it a lot easier.
I managed to fix this problem which manifested itself after my ReSharper trial expired.
Steps to fix are:
Tools/Import and Export Settings
Reset all settings
Back up your config
Select your environment settings and finish
Intellisense started working again straight away.
For me simply hitting Ctrl+Alt+Space to re-enable Autocompletion fixed it.
I had the same problem. It only affected one of my solutions. Others seemed fine.
To correct it I deleted the solution's user options file (.suo).
When I opened the solution again, intellisense was working.
For the benefit of searchers, Nicks suggestion is good, but if you don't want to reset all your settings, you could follow the recommendation in this post.
It states - "go to "Tools | Options | Text Editor | C# | General and check the "Auto list members" and "Parameter information" checkboxes"
I should first note that upgrading my RAM from 4 to 16GB seems to have made this issue go away.
Here's the steps I go through:
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 a likely culprit.
From MSDN:
Close the solution.
Delete the .ncb file.
Reopen the solution. (This creates a new .ncb file.)
Sometimes, it could be because of different extension style that you are using for the files.
In my case Intellisense is working in all the files except for a file in a different project of the same solution.
When I have changed the extension of the file to cxx from cpp,it started working.
The includes and other files in the solution are of extension .cxx or .txx.
Thank you
Save your solution. Closing the VS2010 instance for this solution and re-oprning worked for me.
Here I assume that Intellisense was working OK but stopped for some unknown reason without changing any default settings.
Prabhdeep
After uninstalling ReSharper, the squigglies that show up underneath a syntax error stopped showing up in the code editor.
This blog post helped me fix the issue.
Try this:
Close any open instances of visual studio, delete the folder 10.0 inside `C:\Users[username]\AppData\Roaming\Microsoft\VisualStudio\' and restart the visual studio. Issue will be fixed.
In my case, none of the above worked (although I discovered that sometimes the *.suo file is the trouble maker - in those cases deleting it helps).
I fixed it successfully the following way: Let's assume your solution has the name MySolution. Do the following:
Reset the settings (as described here). Close Visual Studio 2012.
Locate the file MySolution.sln.DotSettings (it is in the same folder as your MySolution.sln file)
Rename or delete it (for example rename it to XMySolution.sln.DotSettingsX so VS won't read it)
Open your solution by double-clicking on the MySolution.sln file
And afterwards Intellisense was working again just fine. I assume the file MySolution.sln.DotSettings got corrupted.
Note: The file MySolution.sln.DotSettings was created and checked in to TFS by a team colleague who had installed ReSharper. The issue occurred on a different PC without ReSharper where the same project was opened.
For me, this was related to an incorrect xaml file build action in an Azure WorkerRole project (bizarre, though it may seem!). Please see my entry in this post if you want to know more:
C# VS2010 Entering break mode failed
The fix for the error in the above thread also resulted in the intellisense starting to work again.
I fixed this problem by removing Sybase Power Designer VS extension.
You can try to disable other extensions.
Exactly the same issue, though would appear only on certain projects (even within a single solution).
Removing the *.*proj.user file (e.g. *.csproj.user) for the projects in question properly reset the missing features ("Go To Definition", "Organize Usings", Intellisense on certain types, etc).
In our case, I suspect this happens sometimes when we switch branches with an SCM that uses a single working directory (like git). If setup properly, it wouldn't track *.user* files but that means that if there are incompatible changes in it across different branches, you need to regenerate it.
So of course the "sometimes" would depend on the current branch and the next branch.
Unfortunately I don't see a very good solution if that's the case. Sometimes you really want to keep the user settings across branches if they're compatible, sometimes you want to regenerate them unconditionally. Ideally, you might even want to only change parts of them when switching, while keeping other parts.
If you never need to keep them and are fine with regenerating them every time, then you can configure your SCM to always remove these files while switching branches (e.g. using hooks for git). This is a pretty naive solution however, doing it more universally correctly would require a smarter system (aware of the semantics behind the .user files and capable of capturing/prompting user intent when needed).
save, close and reopen the source file you are working on. This works every time for me.
Try to add the statement:
<%# Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="IP_Updater.Default" %>
...at beginning of your page. The above example is applied for page Default.aspx written in VB.NET.
This is the problem related to Microsoft MSDN , your MSDN might be getting some problem. The solutions to this is uninstall MSDN and then re-install . before going for this make sure that you system is free from virus attack.
Hope that after doing , the Microsoft Intellisense will start running
I've run into a problem with VS2010 (it also exists in the latest version, SP1 (10.0.40219.1)):
Add an existing Word file to the "Solution Items" and check this new file in.
Check the file out for editing
Double click on the file and edit it in Word (just make some minor changes)
Save the file (CTRL-S)
Now the file is removed from the "Solution Items" in Visual Studio (you may have to repeat the editing and saving a couple of times)
Update: I'm using Visual SourceSafe 2005.
Despite my research efforts I haven't really found anything on this issue apart from this Microsoft page, and I'd like to know whether there is a way to prevent this problem from happening.
Any ideas are more than welcome, thanks in advance.
G.
After further investigation I think I found the reason behind this behaviour and a workaround.
Please also note that the behaviour described in the original question only occurs for files that are added directly underneath a solution or to a folder that is directly underneath a solution.
The reason
I'm not sure whether the following is 100% correct, but the main point is how Word (and probably other MS Office apps as well) saves an existing file:
Save the current version of the file to a temporary file
Rename the original file so it can be used later in case something goes wrong
Copy the temporary file to the location of the original file, using the original file's name
Delete the original file (that was renamed in step 2)
Visual Studio picks up that the file doesn't exist (for a very short time though) and removes it from its tree and the .sln file. This can also be reproduced by manually adding any kind of file, checking it out (if not checked out), renaming it to a different name and then back to its original name => file is no longer shown in Visual Studio.
The workaround
I've created an empty project template following the steps on Microsoft's site. I also set the output to "Class Library" so that the project would compile even if no static main method exists. This template can be used to add a "Documentation" project to an existing solution. Underneath this project you can add files and edit them as you wish, as Visual Studio behaves differently and does not remove the file when it is saved in this constellation.
Obviously this approach is still not very satisfying or elegant, but I hope that it may be helpful for others who might run into the same problem.
G.
I've run into the same issue. I simply undo changes for the solution after I've closed the document file and the solution files will be as they originally were before your document changes.