Program.cs has been corrupted

会有一股神秘感。 提交于 2019-12-02 20:26:24

问题


My Program.cs file was working fine this afternoon. I closed Visual Studio (VS2013 Express) and shut down my computer. Then this evening I turned the computer on again and Program.cs now looks like this:

f£óö'ûRÏ>•]|êêlÇPš—·õGÉ+s
qÖY®ÓÇN­Ž9¯€8ï,? óQwÕ®Åy„Ùrsb^ ƒoÏEl?Qäº6z¹ Ü -³‡kwÎR®Q| €s᪠ å²!dKË*:ÀyÉÿ?l
­Ã&Š‚Ëð.Š›ï,²©“Óü@q:VªÐMãҟ岂¡ËÀÌ<öò§-ž‹66‚j$+”tVeÃÛSVÿ Ïr£pÉ'äûèk0Iœ¾Y/HÅ;vþ
DãjÊÕIÿóõ‘>¤¶ËLw¬,‚ÓHï’$t‡³Ywõ2ŽHíg3É·HVß{fÄèÄKõ™>§ïä ŽíC}r^—  x   èd’—X÷§º~qXPk#

etc.

Any ideas on how to recover it? I tried running Recuva, but that didn't work. There is no copy in the Backup Files folder for this project.

EDIT: I've confirmed that this is happening every time I exit VS2013 and then re-open any project. I was able to use dotPeek to recover the file by decompiling the project's .EXE. However, the file decompiles in a format that requires substantial editing in order to do more work on it, e.g.,

xlApp=new Excel.Application()

becomes

Program.xlApp = (Application) Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));

I need a more practical long-term solution than repeated decompilation. I'll get started with source control, but I'd ideally like to fix whatever problem is causing VS2013 to corrupt the file.

EDIT: This is now happening with other files, in the same project and in other projects in the same solution. In reference to EBrown's comment about encoding, I checked the encoding and the affected files are in "Unicode (UTF-8 with signature) - Codepage 65001" (as are the unaffected files). I am able to restore to the last committed version using git checkout HEAD, but this issue is making my work very inconvenient. I'm hoping to find a solution other than reinstalling VS2013.

来源:https://stackoverflow.com/questions/30233451/program-cs-has-been-corrupted

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