194

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?

0

22 Answers 22

314

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
4
  • 5
    For reference for anyone else searching for this error: I had this happen when the user chose Download ZIP from the repo on GitHub, rather than doing a proper git clone. Instead of dealing with unblocking all the files in the repo, we deleted it and did a normal git clone, and everything worked after that. Jan 21, 2022 at 19:54
  • The second solution worked for me, I just added the root folder path for my project. Jan 9, 2023 at 17:08
  • Had to restart Visual Studio after unblocking the files. May 7, 2023 at 8:09
  • In my case, it was not necessary to restart Visual Studio 2022 (Version 17.7.0) after unblocking .resx files.
    – lubrum
    Aug 12, 2023 at 14:24
105
  1. Open the file explorer. Navigate to project/solution directory
  2. Search for *.resx. --> You will get list of resx files
  3. Right click the resx file, open the properties and check the option 'Unblock'
  4. Repeat #3 for each resx file.
  5. Reload the project.
3
  • 1
    Clicking on Properties doesn't open any window at all. Can you screenshot, where is that Unblock checkbox?
    – T.Todua
    Sep 26, 2021 at 18:48
  • 4
    In 2023, I don't see any Unblock option in the Properties dialog.
    – Tim
    Feb 15, 2023 at 16:55
  • Note that step one specifies the File Explorer, so don't try to find this Unblock checkbox in the Properties panel in Visual Studio. It's in the Windows Properties panel.
    – M H
    Jan 28 at 9:27
44

None of these answers worked for me, I had to do the following:

  1. Start Menu > type 'Internet Options'.
  2. Select Local intranet zone on the Security tab then click the Sites button
  3. Click Advanced button
  4. Enter file://[computer name]
  5. Make sure 'Require server verification...' is unticked

Source: https://superuser.com/q/44503

1
  • Are there any advantages or disadvantages of using the Local Intranet Zone feature? In the case where the "check the Unblock" and the "Powershell the Unblock-File" do not work, I used the "Local Intranet Zon" feature and it worked for me. However, I am not sure if there are any potential risks for setting a particular filepath as a Local Intranet Zone.
    – Ron Zhang
    Jan 5, 2023 at 5:41
29
  1. Find the path from error log and open the file in explorer 2)select the file and right-click -> properties
  2. Then check the 'unblock' option and click on apply enter image description here
2
  • 4
    Not working for me Nov 26, 2021 at 17:55
  • 2
    I had to completely close and reopen visual studio (not just the project) after unblocking the file.
    – Brain2000
    Apr 27, 2023 at 19:58
20

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/

0
14

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.

Visual Studio trusted paths

0
8

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.

enter image description here

2
  • 1
    This solution solves the problem also when the source files are on a second computer on the LAN and you are accessing them through a mapped disk, created for example in this way: net use z: \\192.168.1.10\Git In that case add the second computer address to the trusted sites.
    – tech
    Aug 23, 2022 at 13:07
  • Since our VS project is on a network share and we're opening on a local workstation, VS was complaining about a .resx file. As @tech mentioned, adding the network share to the list of trusted sites (as shown in the screenshot above), fixed our problem (IE: file://Share) None of the other solutions including updating Trust Settings or using PS to unblock the file did.
    – Tikhon
    Jan 13, 2023 at 13:55
6

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.

5

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

5

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

enter image description here

1
  • This worked for me. I had ucopied the source from a zip file.
    – Palle Due
    Nov 15, 2023 at 10:15
4

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).

3

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.

1
  • 1
    Or open with WorPad, NotePlus etc, add a space as indicated and save it. Then restart the app. Apr 11, 2022 at 10:26
3

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.

2

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.

2

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.

2

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

1
  • This worked for me, although as soon as I made a change that altered the .csproj.user file, the error started happening again. I'd never seen it before today, but it's not the first conflict I've had between VS and OneDrive. The cause was another folder failing to sync, which gives the error "the tag present in the reparse point buffer is invalid" when I try to open it. I excluded that folder in OneDrive settings and it solved my issue.
    – Bloopy
    Jul 14, 2023 at 5:25
0

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.

0
0

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.

0

If the above solutions fail, like they did for me, backup all resx files and then delete them. Then try running the project again.

0

if the file is in onedrive folder, when onedrive do the sync, it will lock the file. you can pause onedrive sync.

0

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.

0

If you are facing when committing visual studio project codes add a .gitignore with the following line

.vs/*

Not the answer you're looking for? Browse other questions tagged or ask your own question.