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.
I want to make a backup from the whole project. I also need to rename every backup. I'dont like the way to copy the project folder and rename the folder and the project file.
I've already tried to make it like that:
http://jasonfaulkner.com/VisualStudioExpressProjectBuildBackups.aspx
But it doesn't work, I am always getting the error "Invalid parameters"
Does anyone already tried this?
Thanks
The DPack extension for Visual Studio includes the Solution Backup tool that creates a zip archive of the solution and auto names it.
Manually edit .sln file
This method is entirely aimed at renaming the directory for the project, as viewed in Windows Explorer.
This method does not suffer from the problems in the Remove/add project file method below (references disappearing), but it can result in problems if your project is under source control (see notes below). This is why step 2 (backup) is so important.
1- Close Visual Studio.
2- Create a backup of your .sln file (you can always roll back).
3- Imagine you want to rename directory "Project1" to "Project2".
If not using source control, rename the folder from "Project1" to "Project2" using Windows Explorer.
4- If using source control, rename the folder from "Project1" to "Project2" using the functions supplied by source control. This preserves the history of the file. For example, with TortoiseSVN, right click on the file, select TortoiseSVN .. Rename.
5- In the .sln file, edit all instances of "Project1" to be "Project2", using a text editor like NotePad.
6- Restart Visual Studio, and everything will work as before, but with the project in a different directory.
Alse would recommend TFS, a powerfull tool to do what you pretend. You will be able even to recover previous versions of specific files,if you have any error and you have troubles find it you can see what changes you did since last "check in " etc. There are many options
I've added an executable to my Visual Studio 2010 C# Solution. In the properties of this executable, the executable path is a full path ("C:\Test\MyProgram\MyProgram.exe")
When I deploy my solution (with installshield) on a new PC, the executable is part of the deployed solution together with some source files and the solution file. So far so good.
But when I open the installed solution file (in Visual Studio 2010),
I'm not able to build it because It can't find the executable in the specified path:
("C:\Test\MyProgram\").
Here is the question: How can change the full path of the executable, so it gets the path of where the solution is installed on the new PC. Something like :
"[InstallDir]\MyProgram.exe"
Thanks
Update: I found out that you can use relative path in Application's Executable path. Thanks for all your answers.
You could use TargetDir property
I am just thinking off the top of my head here. There may be a much simpler way. I'm thinking you might want to create a Custom Action that runs at the end of your installer that manually opens the .xxproj file, and manually edits the path of the reference. As another poster stated, you can get the new path from the TargetDir property: http://msdn.microsoft.com/en-us/library/aa372064%28VS.85%29.aspx
Example of creating Custom Actions: http://msdn.microsoft.com/en-us/library/9cdb5eda(v=vs.80).aspx
Add your Executable to your Project TO The Main Dir, right click-> Copy To OutPutDirectory -> Copy
this is easiest way to make your file to copy to your target dir, and have your SourceControl Visual studio plugin manage it.
Your executable should be be somewhere in your project source files structure, perhaps in a subfolder. When you add this executable file to project it should then be added on a relative path which is what you want. If this is not happening you should manually edit csprj file. To do this, right click on project, unload it, right click again and edit project file.
Of course, your executable file should have its property Build Action set to None and Copy to output Directory to what you want.
If for some reason you cannot add this executable directly into your project files structure I'd suggest to use pre-build event to copy it from where it exists into your project files.
I am having some issues with VS C# 2010. Upon create a project I can not seem to locate the project files after saving.
On my laptop they store to C:\Users\james\Documents\Visual Studio 2010\Projects but on my desktop they are being stored in C:\Users\james\AppData\Local\Temporary Projects\mediaplayer
I can seem to locate this folder, even when using the variable %appData%. There is no Local, or Tempory Projects folder. At least I can't see them.
I much preferred the project being stored in Documents. Is it possible to change this? If not, how can I physically access the folder with my project within it?
You can change default folder for new projects in Visual Studio settings.
Click Tools menu
Click Options
Find "Projects and Solutions"
Choose "Project location"
AppData folder is hidden. You have to type its address in address bar manually or you can enable view for hidden files in Windows Explorer.
For Visual Studio 2019 & 2017 :
Click Tools menu
Click Options
Find Projects and Solutions
Choose Locations
and edit the projects location box (the first one)
When you first fully save everything (or exit and choose to save) the project files will be saved in the expected location. It's only in a temporary location until you explicitly save.
C:Windows\Users\"username"\source\repos
this the location of all your projects.
thank you
Projects are stored in Temporary Projects under some settings only if you never save them. If you save the project (File → Save All) then you can choose where to save it. The default is the Projects folder inside your Documents.
Right-click on the tab name of any file you have open and select 'open containing folder' to get there quickly.
Just thought I'd add this as was annoyed at not seeing the file path names when a file just opens via VS by default. (eg, windows terminal app settings menu)
By default Visual Basic 2010 (Or Visual Studio) doesn't notice you when a project is backed up. You can manually check it
Project Backup Location:
You can find the project backed up in C:\Users\<User Name>\Documents\Visual Studio 2010\Backup Files hope that helps.
For you case:
Location to backup project should be C:\Users\james\Documents\Visual Studio 2010\Backup Files\mediaplayer
i have a C# project, it's finished now and i need to make an installer for it.
I added the Setup and Deployment Project and listed all the needed prerequisites, now i just need to copy the database file when the installation finishes.
Just a simple "create a folder named /db/" (in the installation folder) and copy the db.mdf in it.
I'm googleing but i can't find anything i could use.
Any help would be appreciated! Thanks!
Have you looked at the reference documentation: How to: Add and Remove Files in the File System Editor ?
This is typically how you can do it. You can also create folders in there, but note you can have some limitations (with .MSI, you are not supposed to create folder anywhere on the target's disk).