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 [1]:
> 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
[1] https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/unblock-file?view=powershell-6Properties
doesn't open any window at all. Can you screenshot, where is that Unblock
checkbox? - T.Todua
None of these answers worked for me, I had to do the following:
Source: https://superuser.com/q/44503
Complementing @lasse-v-karlsen answer [1]. 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.
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://community.spiceworks.com/topic/2230091-add-onedrive-directory-as-trusted-documents-location
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
None of the above worked.
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.
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.
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.
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 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.
if the file is in onedrive folder, when onedrive do the sync, it will lock the file. you can pause onedrive sync.
I also had this issue due to OneDrive. It turns out OneDrive was failing to finish syncing due to another unrelated folder that gives the error the tag present in the reparse point buffer is invalid
when I try to open it.
I don't have administrator rights on this device to run chkdsk and fix the problematic folder. So instead I went into OneDrive settings and unticked the folder to exclude it from sync. After that OneDrive was able to finish syncing and the .resx errors went away.
If you are facing when committing visual studio project codes add a .gitignore with the following line
.vs/*
Download ZIP
from the repo on GitHub, rather than doing a propergit clone
. Instead of dealing with unblocking all the files in the repo, we deleted it and did a normalgit clone
, and everything worked after that. - Scott Weldon