“There is no editor available for” Can't open .cs

孤人 提交于 2019-12-18 07:36:51

问题


My computer shut down while working on a project and when I opened C# again and recovered it, I got an error saying

There is no editor available 'for filename.cs'
Make sure the application for the file type (.cs) is installed

And now I can't access my code at all.

I'm using Visual C# 2010 express.

I tried opening it directly and it brings up C# but the .cs file opens up in notepad. The file size is 30kb so it didn't get deleted. And there is still a working .exe in the debug folder of the last run. Is there any way to recover the code?


回答1:


To fix the problem you need:

  1. NotePad++

And you should follow this simple steps:

  1. Close Visual Studio.

  2. Go to the Backup Folder of your VS version usually in: "C:\Users(your user name)\Documents\Visual Studio (year)\Backup Files\your project or application name".

  3. Open the last Backup file of your corrupted file, usually the name format is : "Recovered-month.-day-year-time.(Your File Name).cs" with NotePad++, and copy the source code.

  4. Go to your corrupted file in the project folder and open it with NotePad++, Edit => Select All => Past the source code and Save.

  5. Go to windows start list and search for: "Visual Studio Tools" folder, open it and double click on: "Developer Command Prompt for VS(year)".

  6. Write this two codes in the Developer Command Prompt: "devenv.exe /setup" and then "devenv /resetskippkgs" .

  7. Open your project.

Note: if this didn't work for you try to do the steps before in this arrangement:

1) => 2) => 3) => 4) => 7) => 1) => 5) => 6) => 7)

and your problem will be fixed.

It works 100% for me, i hope this will helps you!




回答2:


Try to open the .cs file in notepad. Then copy the code and open a new codefile and copy the code in there. That should help.




回答3:


I had the exact same problem happen and was able to fix it:

My issue was due to incorrect line endings / a null terminator was accidently introduced when I did a find / replace using Visual Studio. This threw the whole thing out of whack. My assumption would be because the Null terminator is used to signify the end of the document and I had accidently introduced it in the middle of the document (which also led to bizarre compile errors).

A simply find / replace through another editor (Notepad++) allowed me to find the incorrectly placed null terminator and remove it.




回答4:


I had the same problem with a .cs file in Visual Studio 2017 after a crash. My solution was as follow:
Go to the corrupted file in Explorer. In my case the corrupted Form1.cs contained only NULL values due to the crash (you can test this by opening in Notepad++ for example). Just backup or delete this file. In my case there was also a backup file in the same folder named like Form1.cs~string.TMP. Rename this to Form1.cs and reopen your project and double click on the Form1.cs and it will open successfully.




回答5:


As mentioned in the comments, your best option now is to repair or reinstall Visual Studio.




回答6:


You should repair or worst case scenario reinstall VS.

I will say though you might be interested in looking into some version control software so you have backups of your code. There are plenty of free options out there so it wont cost you, but this software will allow you to easily rollback if you break something, and if you do have a crash like this and loose your work you only loose the changes since the last checkin.




回答7:


C# has a "backup" folder which I wasn't aware of, but I found a backup version inside it which made me only lose a few minutes of work. =)




回答8:


There is no way to get the .cs file again (In my case after PC crash, two notepad files opened with no text in it, if I try to open the .cs file with notepad++ only null separator values). Have to redo the code again.




回答9:


Try to restore it from early date - it worked for me :)




回答10:


In case you are using source control(which you should) you can just undo pending changes on the corrupted file. Worked for me



来源:https://stackoverflow.com/questions/7976638/there-is-no-editor-available-for-cant-open-cs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!