I am having an inconvenience when putting icons to the forms of my application made in C#
with WinForms
(VisualStudio 2022) and it is that every time I try to compile I get the following error:
The Form1.resx file cannot be processed because it is on the Internet or in a restricted area, or is marked with the web. Remove this check if you want to process the files.
I tried adding the .ico files to the project and the same thing happens. I tried putting them on the desktop and the same thing happens. I tried the .ico files with the different measurements (16x16/32x32/64x64) and none of them work. I always get the same error, once I remove that .ico file it compiles again without problems. Attached images:
I've even tried creating an Images folder inside the project and adding the .ico inside but it didn't work either:
The .ico is not locked:
Does anyone have an idea how I can fix it?
Try the following:
variant 1
1) Close Visual Studio if you have it open.
2) Open Windows Explorer and navigate to the folder where your project is, look for all your files with * .resx extension there and go one by one by right clicking and selecting the properties option and checking the unlock option for each file with extension * .resx (Which in your case may be nothing more than the Form1.resx file , since it is the one that gives you the error).
3) Reopen Visual Studio .
4) Just in case once you have opened your project again, go to your solution explorer right click on your project and select the rebuild option .
Note: Take note that this variant is with the extension * .resx files .
Variant 2
Another variant could be to edit your * .ico files (I use a tool called IcoFXPortable , you could also use Photoshop ), you would open your * .ico files with one of these editing tools and go to the Save As option , then fine you could save by overwriting your * .ico file or giving it another name, this edition of the * .ico file being the one you would use in your project.
Variant 3
Inside Visual Studio go to Tools/Options/Trust Settings menu and add the project path as a trust path.
Variant 4
Go to the path where your project is, and open your * .resx file that has problems, copy all its content and delete this file. Then create a new text file, paste the previously copied content there and save it with the same name and extension as the file you previously deleted. Then open Visual Studio and rebuild your project.
Variant 5
1) Open the Start menu and type 'Internet Options' .
2) In the window that opens, go to the Security tab and select the Local Intranet option and click the Sites button .
3) Then click on the Advanced button.
4) Specify the file to unlock: file://[computer name]
5) Make sure the 'Require server verification (https:) for all sites in this zone' checkbox is unchecked.
References:
https://qastack.mx/programming/51348919/couldnt-process-file-resx-due-to-its-being-in-the-internet-or-restricted-zone-o
https://docs.microsoft.com/en-us/visualstudio/ide/reference/trust-settings?view=vs-2022
https://developercommunity.visualstudio.com/t/couldnt-process-file-abcresx-due-to-its-being-in-t/291761
The solution was to do it programmatically: