Visual studio view (.cshtml) crashed and cannot recover - c#

My view file(.cshtml) crashed and turned into as shown in image below. Actually, it happened right after the system was unexpectedly shut down. I tried other solutions like clearing temp files from bin. I tried to open it with notepad++ but it didn't work.
Any help will be appreciated.

Download WinHex program and open your corrupted file with it.
Go: Tools > Open Disk
Navigate to your corrupted file
Double click on it
If there is non-zero values, just copy and paste all this data to you new file.

I'm afraid you've lost it.
If you have a VCS in place (which you should), restore the file from there. Also, see if there are any previous versions of the file and try to fish it out from over there. Lastly, check your general-purpose backups, if you happen to have those.

If you have published your content, then in visual studio you can right click on the specific file and choose 'replace [fileName] from server'. This will download an uncorrupted version of your content from the published site.
Hope this helps.

Related

Could not find file 'bin\Antlr3.Runtime.pdb' Error when creating deployment package

I'm getting the following error when tried to create deployment package.
"Copying file bin\Antlr3.Runtime.pdb to obj\Release\AspnetCompileMerge\Source\bin\Antlr3.Runtime.pdb failed. Could not find file 'bin\Antlr3.Runtime.pdb'"
Can someone tell me what is happening and how to solve it
First of all delete whole file from bin folder
Remove reference of this "Antlr3"
Close Visual Studio
Open .croj project file in Notepad
find 'Antlr3.Runtime.pdb' and you found this in "ItemGroup". See ScreenShot
Remove below lines and save file.
Open project and re-rebuild solution.
It's working fine for me. Let me update here this is work for you???
For some reason "Clean" and "Rebuild" leaves the dll in the bin folder, but don't bring the missing .pdb.
The manual deletion of the entire bin's content and consequent "Rebuild" does the job

Couldn't process file resx due to its being in the Internet or Restricted zone or having the mark of the web on the file

I am facing an issue while debugging c# API Coding in Visual studio 2017. Debugging not started and showing a error message like
Couldn't process file resx due to its being in the Internet or Restricted zone or having the mark of the web on the file. Remove the mark of the web if you want to process these files.
Any idea about this error message?
If you downloaded the file from the internet, either separately or inside a .zip file or similar, it may have been "locked" because it is flagged as coming from the internet zone. Many programs will use this as a sign that the content should not be trusted.
The simplest solution is to right-click the file in Windows Explorer, select Properties, and along the bottom of this dialog, you should have an "Unblock" option. Remember to click OK to accept the change.
If you got the file from an archive, it is usually better to unblock the archive first, if the file is flagged as coming from the internet zone, and you unzip it, that flag might propagate to many of the files you just unarchived. If you unblock first, the unarchived files should be fine.
There's also a Powershell command for this, Unblock-File:
> Unblock-File *
Additionally, there are ways to write code that will remove the lock as well.
From the comments by #Defcon1: You can also combine Unblock-File with Get-ChildItem to create a pipeline that unblocks file recursively. Since Unblock-File has no way to find files recursively by itself, you have to use Get-ChildItem to do that part.
> Get-ChildItem -Path '<YOUR-SOLUTION-PATH>' -Recurse | Unblock-File
Open the file explorer. Navigate to project/solution directory
Search for *.resx. --> You will get list of resx files
Right click the resx file, open the properties and check the option 'Unblock'
Repeat #3 for each resx file.
Reload the project.
None of these answers worked for me, I had to do the following:
Start Menu > type 'Internet Options'.
Select Local intranet zone on the Security tab then click the Sites button
Click Advanced button
Enter file://[computer name]
Make sure 'Require server verification...' is unticked
Source: https://superuser.com/q/44503
Find the path from error log and open the file in explorer
2)select the file and right-click -> properties
Then check the 'unblock' option and click on apply
Complementing #lasse-v-karlsen answer.
To unblock all files recursively, run from powershell as administrator inside the folder you want:
gci -recurse | Unblock-File
source link:
How to Unblock Files Downloaded from Internet? - Winhelponline
https://www.winhelponline.com/blog/bulk-unblock-files-downloaded-internet/
Although this is an older question, I spent several hours tracking down a way to handle this error when it applies to multiple files that are located in sub folders throughout the project.
To fix this for all files within a project, Visual Studio -> Tools -> Options -> Trust Settings and add the project path as a trusted path.
If you are using OneDrive, or any similar network drive, you have 2 options:
1) the easy one is to move the folder to a local directory inside your PC (eg:. C:).
2) but if you want to keep using OneDrive I would recommend to add it to the trusted sites on the internet explorer options and that will fix the problem.
I had this issue on resx files in my solution. I'm using Onedrive. However none of the above solutions fixed it.
The problem was the icon I used was in the MyWindow.resx files for the windows.
I removed that then grabbed the icon from the App Local Resources resource folder.
private ResourceManager rm = App_LocalResources.LocalResources.ResourceManager;
..
InitializeComponent();
this.Icon = (Icon)rm.GetObject("IconName");
This happened after an update to VS2019.
None of the above worked.
The "Unblock" option is not present in the explorer properties.
Recreating file, adding folder (and resx file) to Tools->Options->Trust Settings does not work.
The solution was to copy the project locally (from the network drive).
Solution: Edit and save the file!
From VisualStudio go to the View and expand to see it's resx file
Right-click menu select OpenWith... XML (Text) Editor.
Just add a space at the end and save.
If, like me, you have diligently followed all the above solutions and the error is still there, try closing and reopening Visual Studio.
Obvious, I know, but perhaps I'm not the only one who's become fuzzy-brained after staring at a computer screen all day.
None of the above worked for me.
This happened to me after I added a new button to a toolstrip on a winform. When the button uses the default image of System.Drawing.Bitmap (in image property) this error arose for me. After I changed it to a trusted image (one added to my resource file with 'Unlock' option checked) this error resolved itself.
I use OneDrive as well and I fixed the issue by adding Microsoft/Onedrive domains to trusted sites.
Internet options->Security->Trusted Sites->Sites-> and add there:
https://marq-my.sharepoint.com
https://*.onedrive.com
https://*.office365.com
https://*.office.com
After that: Close->Ok->Restart PC
References:
https://www.marquette.edu/its/help/onedrive-for-business/onedrive-for-business-as-a-trusted-site.shtml
https://community.spiceworks.com/topic/2230091-add-onedrive-directory-as-trusted-documents-location
I stumbled upon another possible reason of this error. If you use NTFS symbolic links in your project tree, and probably subst'ed drives, you may get this error even if they point to your local drive. If this is the case, try to avoid the situation when .resx files are reached via symlinks.
None of the suggestions above worked for me so I created a new file with a slightly different name and copied the contents of the offending file into the new file, renamed the offending file and renamed the new file with the offending file's name. Worked like a charm. Problem solved.
If the above solutions fail, like they did for me, backup all resx files and then delete them. Then try running the project again.
Its works perfect by using Powershell command as below (It's very powerful cammand to Unblock all files inside a project folder). Below is the example how to use it:
Powershell cammand:
PS C:\Users\kri> Get-ChildItem -Path 'C:\Users\kri\Downloads\ProjectFolder' -Recurse | Unblock-File
The only solution that worked for me was to copy the solution to a folder outside OneDrive, build and run the solution. Finally, copy the folder back to OneDrive
I also faced this issue when i tried to run a downloaded zipped code from github.
Solution: I simply cloned the code from github instead of downloading and code run successfully without errors.

projects disappear from VS 2015 solution after reopening

I have a weird problem with my C# solution file. I noticed that my .sln file itself was missing. So I created an empty .sln file, added my Existing projects to it, built and it worked fine. When I close and reopen Visual Studio, the .sln file I created is there but projects added to the solution have disappeared. How to fix this?
It sounds like you are having issues with write permissions in your solution. Is the folder your solution is in under any type of source control?
Try creating a new folder at the root of your harddrive. Something like c:\testsolution
Copy your project files there and then try adding you solution file again.
Good luck.
Most likely this is an issue with not saving the changes to VS solution file.
Before closing Visual Studio, take an extra step to make sure all changes are actually saved (File-> Save All). Then manually verify that all your projects successfully made it to the solution file by opening the solution file with a text editor. If you don't see your projects listed, try editing the file yourself to verify you have the necessary permissions.

Files show as hidden in Visual Studio 2012

Hei,
So we have a whole group of people working on the same project and every now and then some files show as hidden, you know the blank file icon like obj or bin.
See my font and texture? They should be normal.
So, I can see them in the folder but not in solution explorer without hitting the Show Hidden Files. I can also modify them but I would like them back.
I have been trying to see if there was a solution but all I get is blogs on how to show hidden files.
So I found this thread
Visual Studio 2012 and missing files
that seems to be giving the reason of my problem. People are not saving properly before pushing to github.
Now is there a solution to this?(apart from saving properly) Can I make all of those files become normal files?
Cheers
Simply right click the files/folders and include them to source control again.
This usually happens if people check in new files/folders but do NOT check in the updated project file, too. The project file contains a list of all files which should be included within the solution. If this runs out of sync, exactly this crap will happen... ;)
Simply instruct your folks to properly check-in. Or do code review on check-in and verify that the project/solution file(s) are also checked in.
They show up as hidden because they're not part of the project/solution, but they are on your file system.
You can right-click the files and click Include in Project
If this does not solve the issue after checking in. The project file is what is not properly getting checked in.
Probably the problem is that they are not pushing the project file (file with extension .csproj). It holds all references to files included on the project so it needs to be pushed when new files are added.
Let everyone know that they need to push this file in order to everyone to catch latest changes on project.

InstallShield Without The Program Files Folder?

I feel like I must be missing something very basic. I have a legacy WinForms application with quite a few projects in it and I need to create an installer for it but I only have VS2012. So I installed InstallShield LE and researched how it all works and the output it gives me is a setup.exe file, setup.ini file, [appname].msi file, and 0x0490.ini file.
It then also has a folder called program files that has all of the files that I specified for a part of the installation and all of this is in the DISK1 folder. That's all fine and great but I've never seen a setup wizard that had a big folder of files sitting next to it, how do I just wrap everything up into one setup wizard without having to have the folder of goods in it?
Sounds like you're building a release with the compression turned off.
In the solution explorer tree, expand 'Prepare for Release' and select the 'Releases' node. Find the release you're using in the tree that appears on the left side of the window.
You should see a setting called 'Compression'. If it's set to 'Uncompressed', that's your problem. Change it to Compressed.

Categories

Resources