I have an issue while I try to build project in VS2012.
It cannot build due to the error:
Couldn't process file xxx.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.
Here is a similar question.
but I tried that option and had no luck, because I did not download the file from the internet. That project was built from scratch. In project after selecting Properties, in Windows Explorer nothing happened. I do not have the "unblock" option, only the default three options (read only, hidden, and archived).
I have the same error and cannot build or rebuild the project. I have a theory that it is a recent error after updating Windows. Before the update, everything worked fine. Any ideas?
Go to xxx.resx file in Windows File Explorer. Right-click and select properties. At the bottom of the the dialog is an "unblock" option:
Check this and click Apply. Clean your solution and it will build.
In my case I had the same problem with many files.
My solution with VS Prof. 2017 V15.95 was:
Open powershell and execute dir -Path [directory path] -Recurse | Unblock-File
Rebuild all
On the solution folders locate abc.resx.
Open the file using any text editor, preferably Notepad++.
Locate and delete any node starting with <data
Example. This is what you should delete.
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAMAICAAAAEAIACoEAAANgAAAGBgAAABACAAqJQAAN4QAACAgAAAAQAgACgIAQCGpQAAKAAAACAA
AABAAAAAAQAgAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
///////////8AAB/////////
</value>
</data>
Reload or reopen your solution and build. You are ready to go.
Had the same problem after updating to VS 2017 v15.8.5, and none of the solutions above or on other forums worked for me.
So, since a .resx file is just XML, I just copied the content, deleted the original file and recreated it with the copied content.
That was the only thing that worked, and it worked first time.
A quick way to remove this mark of the web for multiple files and folders recursively for me was to
Zip them up.
Delete originals.
Unzip.
I'm not really sure either, I have the exact same issue.
But, what i did, was hit view in file explorer.
Then, i clicked show hidden items.
Finally, i went back to my folder and clicked on the .vs folder, my project/file name, v15, Server, sqlite3, and deleted DB.Lock.
I reopened the project, clicked build, and it worked perfectly.
This worked for me, it might/might not for you.
I also encountered this issue recently. The error began occurring after I set the icon of a Windows Form.
Researching for the cause and solution almost led me nowhere, because I did not download the icon from the internet, nor was I referencing a web-based icon file. It was stored entirely on my local machine.
After some more researching and digging around, I was able to figure out exactly what was causing the problem. I have Microsoft One-Drive installed on my machine. The directory in which the icon file was located is managed/synced by One-Drive. That fact was somehow tricking Visual Studio into believing the file was located or downloaded from the internet.
The solution proved to be very simple. I removed the icon from the form, as well as from the corresponding .resx file. Then I moved the icon file to another directory not associated with One-Drive. Finally, I was able to use that icon in my Windows Forms application without getting this error.
I understand there are other possible causes for this error. But if in your case, the issue happened after setting a form's icon--and if you have One-Drive (or perhaps another cloud-based storage solution) installed--then check to be sure that icon file is not in a directory managed by that service. If so, relocate it and change the form's icon property to point to the new location.
To fix this for multiple files within a project, Visual Studio -> Tools -> Options -> Trust Settings and add the project path as a trusted path.
Using VS 2019, and building against source stored on an Azure shared file system. I think I may have just tracked down a work-around, and it has to do with the Icon as referenced above by Jake above. If I add the icon to the form's resource file (that really long string), The error occurs.
However, if I add the Icon to the Project's resources, delete the Icon from the form's resource file, and change form to set the Icon manually...
this.Icon = MyProjectName.Properties.Resources.MyIcon;
The error goes away.
I found this solution on another forum. My project resided on a file share, so I had to enter file://[file share] for Step 4 below. I am running VS2019 on Windows 10.
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] or file://[file share]
Make sure 'Require server verification...' is unticked
I had the same issue in Windows 10 VS 2019 16.4.457 (previous version of VS 2019 had no problems).
The "marked for web" error shows only after I moved the project under One-Drive.
If I move the project back to a local drive the error doesn't show.
As Anthony Gingrich suggested, I tried to move the project images to a local directory without success.
The solution that works for me was, for each image, in the "Select Resource dialog" use "Project resource file" instead "Local resouce".
Please guys, I already fixed the issue, this is cause by OneDrive, please close your OneDrive with the use of task manager or close the icon OneDrive's Hidden Icons on the taskbar
I just ran into the same issue and also tried the Unblock option from explorer with no luck. I even restarted VS with no luck.
However, I'm not sure which combination did the trick but I opened the form as well as the resx file from within VS, just to see if I can open it, which opened fine. I then did a clean and rebuild and that appeared to do the trick. If it doesn't try restarting VS after the clean then rebuild.
I had a similar issue and the problem was an image that I had downloaded and added to my Resources. Not completely sure why that was the only image that gave me problems, however, I opened my abc.resx file giving me issues an a text editor, removed the node starting with " (it was the last and only node) just like Albert Alberto mentioned. Saved the changed, cleaned and rebuilt my solution and it all works! The image didn't render but it only took a second to go back and add the image. It wasn't removing the entire file, just the node that was causing the issue.
I had the same problem on Windows 10, VS 2017 (15.9.13). I sent myself a project from work through Dropbox so I could try a couple of things from home. But when I tried to build it VS gave me the 'marked for web' error.
After trying the solutions above without success I began experimenting. I was able to solve this by using the method listed above (right click -> properties -> unblock), but I had to do it for each of the images in the Resource folder--and I had to do EACH FILE individually since the 'unblock' option was not available on group-selects. I actually unblocked each source file in the project as well before trying to rebuild so I am not sure if both are required.
Its a bit of a pain--probably a huge pain for larger projects--but it absolutely got the project building again.
EDIT: I did find this article afterwards about unblocking entire folders--even recursively but have not tried it: https://www.winhelponline.com/blog/bulk-unblock-files-downloaded-internet/
None of these worked for me. I fixed it by converting the embedded base64 into a linked resource:
I found out the issue was with the embedded base64 image I had in the .resx (as the issue went away removing the data tag as explained in this question but that meant I removed the image) so I converted the embedded image into a .png file and made a link to that in the .resx.
To do that: open the .resx file in Visual Studio 2019 and double-click the image, and then click Ok and Yes in the following prompts that will appear so VS will convert the embedded image into a linked resource (sorry I can't upload pictures yet):
Hope it helps!
From my original comment.
After reading every article here and trying every suggested action I'm out of things to try:
I have a namespace issue in Visual Studio 2015 - in a XAML file in UWP.
The concrete error message is:
"The name "FieldManagementViewModel" does not exist in the namespace
"using:StudyConfigurationClient.ViewModels"".
This is my XAML:
This is the structure to show, that the folder and file actually exists, folder structure equals namespaces in this project:
I've looked all references and namespaces through, I've repaired Visual Studio 2015, I've cleaned and rebuilt several times and changed platform for the build back and forth - I'm out of options.
What worked for me:
Remove the problematic XAML tag, so that solution will build
Rebuild project
Restore the tag
I think VS falls into a chicken & egg situation here, in that it needs newly added classes built so that XAML can see them, but it can't build them because XAML can't see them.
Just add this solution to this probelm:
- Close and re-open Visual Studio
In my case the problem occurred in App.xaml. In the properties for App.xaml the BuildAction had somehow been changed to Page. After restoring the BuildAction to ApplicationDefinition the problem went away. (See also this related answer.)
Thanks for helping - this issue magically went away when I pulled a change from git, which shouldn't affect this in any way. Sorry for not being able to help others, but I haven't got a clue about what happened.
There is a web app I'm trying to make publish in order to upload it by CuteFtp Pro.
I usually being doing this with no problem. But this time, I'm facing crazy error! Actually, as I right-click the solution and click to Publish using File System option choosing an appropriate path for that, finally I got an Error:
Error
Copying file Images\512px-Icon_-_upload_photo_2.svg.png to obj\Debug\Package\PackageTmp\Images\512px-Icon_-_upload_photo_2.svg.png failed.
Could not find file 'Images\512px-Icon_-_upload_photo_2.svg.png'.
0 0 GiftShop
I really don't know and have no idea about this error since there is no file by the name of
512px-Icon_-_upload_photo_2.svg.png
In fact, I never had an image by that name through the project!! What could be the reason?
I'm really getting frustrated in challenging with that error.
Anybody could help me on this please?
Thank you so much
This basically happens whenever we delete the contents from the folder but forget to remove from Visual studio solutions.
To Resolve this follow below steps:-
Go to visual studio solution explorer and right click on the specific content
exclude(yellow marked files) from project.
right click and remove those files from visual studio solution explorer.
Hoping this will help you :)
Try removing the file from your project (right click and exclude).
search for the string name of file in all the files of the project. Remove the line and you are done.
Whats the best guess is that it must have been referenced in one of the CSS you are using especially if you are using Jquery or any of its plugin..
Do one thing exclude your obj folder from project.This is the best way for those kind of errors.
In your solution explorer there is one tab with tool tip "Show All Files".Click on it and it will show you all files.
There is one another way
Update: went into Project --> Package/Publish Settings, and clicked "Exclude generated debug symbols." The project began publishing with no issue.
one more solution for you
Are you seeing the file in the project? If so right click and tell it to remove the "ghost" file from the project. Once you do that I would try and publish again.
If its not showing the project, you might be able to create a fake file with the same name (just put some text in there so the size isn't 0kb) and in the same location as the other asp files. Make sure the "show hidden files is selected" and add it to the project and then promptly delete. This would essentially fix the corruption of VS thinking the file exist.
Hope it works.
Look into your solution and exclude this image file, but remember to click on Show All Files, and try to rebuild the solution.
Update 1
I ran yesterday with the same issue, it was an image not included in the project. Please go to Solution Explorer click on Show All Files and check 512px-Icon_-_upload_photo_2.svg.png image is included in the project or not, if it in gray color so it's not included in the project and if has a yellow icon please remove it from the project.
I am working on a WPF, C# 3.0 project, and I get this error:
Error 1 Metadata file
'WORK=- \Tools\VersionManagementSystem\BusinessLogicLayer\bin\Debug
\BusinessLogicLayer.dll' could not be found C:\-=WORK=- \Tools
\VersionManagementSystem\VersionManagementSystem\CSC VersionManagementSystem
This is how I reference my usercontrols:
xmlns:vms="clr-namespace:VersionManagementSystem"
<vms:SignOffProjectListing Margin="5"/>
It happens after every failed build. The only way I can get the solution to compile is to comment out all my user controls and re-build the project, and then I uncomment the usercontrols and everything is fine.
I have checked build orders and dependencies configurations.
As you can see, it seems to have truncated the DLL file's absolute path... I have read that there is a bug with the length. Is this a possible problem?
It's very annoying and having to comment, build, and uncomment, the build is becoming extremely tiresome.
I just had the same problem. Visual Studio isn't building the project that's being referenced.
Written Instructions:
Right click on the solution and click Properties.
Click Configuration on the left.
Make sure the check box under "Build" for the project it can't find is checked. If it is already checked, uncheck, hit apply and check the boxes again.
(Optional) You had to do it for both Release and Debug modes on the solution properties.
Screen capture Instructions:
They say a picture is worth a thousand words. Click on the GIF to zoom in, and hopefully it will be easy to follow:
This can still happen in newer versions of Visual Studio (I just had it happen on Visual Studio 2013):
Another thing to try is to close Visual Studio and delete the .suo file that is next to the .sln file. (It will be re-generated the next time you Save all (or exit Visual Studio)).
I've had this problem when adding new projects to the solution on another machine and then pulling the revisions in, but the .suo file can be corrupted in other cases as well and lead to very strange Visual Studio behaviour, so deleting it is one of the things I always try.
Note that deleting the .suo file will reset the startup project(s) of the solution.
More on the .suo file is here.
The suggested answer did not work for me. The error is a decoy for another problem.
I found out that I was targeting a slightly different version of .NET and this was flagged as a warning by the compiler, but it was causing building to fail.
This should have been flagged as an error and not a warning.
Well, my answer is not just the summary of all the solutions, but it offers more than that.
Section (1):
In general solutions:
I had four errors of this kind (‘metadata file could not be found’) along with one error saying 'Source File Could Not Be Opened (‘Unspecified error ‘)'.
I tried to get rid of ‘metadata file could not be found’ error. For that, I read many posts, blogs, etc. and found these solutions may be effective (summarizing them over here):
Restart Visual Studio and try building again.
Go to 'Solution Explorer'. Right click on Solution. Go to Properties. Go to 'Configuration Manager'. Check if the checkboxes under 'Build' are checked or not. If any or all of them are unchecked, then check them and try building again.
If the above solution(s) do not work, then follow sequence mentioned in step 2 above, and even if all the checkboxes are checked, uncheck them, check again and try to build again.
Build Order and Project Dependencies:
Go to 'Solution Explorer'. Right click on Solution. Go to 'Project Dependencies...'. You will see two tabs: 'Dependencies' and 'Build Order'. This build order is the one in which solution builds. Check the project dependencies and the build order to verify if some project (say 'project1') which is dependent on other (say 'project2') is trying to build before that one (project2). This might be the cause for the error.
Check the path of the missing .dll:
Check the path of the missing .dll. If the path contains space or any other invalid path character, remove it and try building again.
If this is the cause, then adjust the build order.
Section (2):
My particular case:
I tried all the steps above with various permutations and combinations with restarting Visual Studio a few times. But, it did not help me.
So, I decided to get rid of other error I was coming across ('Source File Could Not Be Opened (‘Unspecified error ‘)').
I came across a blog post: TFS Error–Source File Could Not Be Opened (‘Unspecified error ‘)
I tried the steps mentioned in that blog post, and I got rid of the error 'Source File Could Not Be Opened (‘Unspecified error ‘)' and surprisingly I got rid of other errors (‘metadata file could not be found’) as well.
Section (3):
Moral of the story:
Try all solutions as mentioned in section (1) above (and any other solutions) for getting rid of the error. If nothing works out, as per the blog mentioned in section (2) above, delete the entries of all source files which are no longer present in the source control and the file system from your .csproj file.
In my case it was caused by a .NET Framework version mismatch.
One project was 3.5 and the other referencing project 4.6.1.
Visual Studio 2019 this worked for me:
Close Visual Studio
Delete the hidden .vs folder
Reopen Visual Studio and rebuild the solution.
Closing and reopening Visual Studio 2013 worked for me!
Well, nothing in the previous answers worked for me, so it got me thinking about why am I clicking and hoping when as developers we should really try to understand what is going on here.
It seemed obvious to me that this incorrect meta data file reference must be held somewhere.
A quick search of the .csproj file showed the guilty lines. I had a section called <itemGroup> that seemed to be hanging onto the old incorrect filepath.
<ItemGroup>
<ProjectReference Include="..\..\..\MySiteOld\MySite.Entities\MySite.Entities.csproj">
<Project>{5b0a347e-cd9a-4746-a3b6-99d6d010a6c2}</Project>
<Name>Beeyp.Entities</Name>
</ProjectReference>
...
So a simple fix really:
Backup your .csproj file.
Find the incorrect paths in the .csproj file and rename appropriately.
Please make sure you backup your old .csproj before you fiddle.
In my case, I have my installed directory in mistaken ways.
If your solution path is something like "My Project%2c Very Popular%2c Unit Testing%2c Software and Hardware.zip", it cannot resolve the metadata file, perhaps we should prevent some invalid words like %2c.
When a repository is cloned from certain sites, the directory name is URL encoded. Which would convert space characters in directory names to %20, forward slashes to %2f, underscores to %5f, etc. Although, I'm not sure why the % symbol is breaking things.
Renaming the path into a normal name resolved my issue.
I also met this problem. Firstly you have to manually build you DLL project, by right-click, Build. Then it will work.
In my case, the problem was caused by a simple build error,
error CS0067: The event 'XYZ' is never used
that, for any reason, did not show up in the error window.
Because of that, the Visual Studio build system seemed to miss the error and tried to build dependent projects, which in turn failed with the annoying metadata message.
The recommendation is -as stupid as it may sound-:
First look at your Output Window!
It took me half an hour before this idea hit me...
I got the same error "Metadata file '.dll' could not be found", and I tried several things described above, but the reason for the error was that I was referencing third-party DLL file which was targeting a .NET version higher that my project target .NET version. So the solution was to change the target framework of my project.
I added a new project to my solution and started getting this.
The reason? The project I brought in was targeting a different .NET framework (4.6 and my other two were 4.5.2).
For me, it was trying to find a DLL in a path that used to contain the Project, but we'd moved it to a new directory. The Solution had the correct path to the Project, but Visual Studio somehow kept looking in the old location.
Solution: Rename each problem Project - just add a character or whatever - then rename it back to its original name.
This must reset some global cache of some kind in Visual Studio, because this clears both this issue up and several like it, while things like Clean do not.
It looks like such kind of errors related to the fact that Visual Studio doesn't provide correct information about an error. The developer doesn't even understand the reason for the failed build. It can be a syntax error or something else. In common, to solve such problems you should find the root of the problem (for example, look at the build log).
In my case the problem was in fact that the Error List window didn't show any errors. But really there were syntax errors; I found these errors in the Output window, and after fixing them, the problem was solved.
For me it occurred when I included a new project to a solution.
Visual Studio automatically selects .NET framework 4.5.
I changed to version .NET 4.5.2 like the other libraries, and it worked.
If you have a space in your solution name, this will also cause the issue. Removing the space from your solution name, so path doesn't contain %20 will solve this.
Coming back to this a few years later, this problem is more than likely related to the Windows maximum path limit:
Naming Files, Paths, and Namespaces, Maximum Path Length Limitation
For me the following steps worked:
Find the project that is not building
Remove/add references to projects within the solution.
I was pulling my hair out with this problem also, but after trying the previous answers the only thing that worked for me was to open each project in my solution 1 by 1 and build them individually.
Then I closed Visual Studio 2013, reopened my solution and it compiled fine.
It's strange, because if I clicked each project in my Solution Explorer and tried to build them that way, they all failed. I had to open them alone in their own solutions.
In my case the issue was that I'd manually deleted a non-compilation file which was marked as "missing". Once I deleted the reference to the now-missing file and recompiled - all was well.
My instance of the problem was caused by a common project that had a duplicate class name in it (under a different filename). It is strange that Visual Studio could not detect that and instead just blew up the build process.
I got this problem in Visual Studio 2012 in a solution that had many projects. Rebuilding each project in the solution manually in the same order as the Project Build Order (right-click and rebuild in Solution Explorer) fixed it for me.
Eventually I got to one that gave me a compile error. I fixed the error, and the solution would build correctly after that.
I too had the same error. It hides as in the below path.
The path which I referred to for the DLL file is like "D:\Assemblies Folder\Assembly1.dll".
But the original path in which the assembly referred was "D:\Assemblies%20Folder\Assembly1.dll".
Due to this path name variation, the assembly could not be retrieved from its original path and hence throws the "Metadata not found" error.
The solution is in Stack Overflow question How do I replace all the spaces with %20 in C#?.
Most of the methods explained here did not solved the problem for me.
Finally, I fixed the problem by applying the following steps:
1. Close Visual Studio.
2. Delete all the contents in the bin folders of each project.
3. Open solution and rebuild.
I hit and solved this problem today on VS2022 in a solution with a Blazor project.
The underlying problem is that I had introduced a routine C# compilation error
in C# code declared in a .razor file. VS2022 was dropping the display of the error from the Build Error List tab. I found the C# error by scanning the build output in the Output console log tab where my C# error was described as expected.
p.s. In case you are wondering, I had a Unit Test project referencing my Blazor web project. The project DLL reference from the Unit Test project to the Blazor app was complaining about the missing Blazor DLL.
Based on the error message I don't believe the file path is being truncated. It looks to just be incorrect. If I'm reading the message correctly it appears to be looking for the DLL file at ...
WORK=-\Tools\VersionManagementSystem\BusinessLogicLayer\bin\Debug\BusinessLogicLayer.dll
This is not a valid path. Is it possible that you have a macro definition in the build process set to an invalid value?
I'd faced the same problem. In my case I'd referenced to a class library project with higher .Net version than my project and VS failed to build the project and raised the same error you posted.
I simply set .Net version of my class library project(the one that had broken the build) identical to the .Net version of referenced project and problem solved.
Just pointing out the blatantly obvious: if you don't have "Show output window when build starts" enabled, make sure you're noticing if your build is failing (small "build failed" error in lower left)!!!!
I had this error when I was trying to publish a web application. Turned out that one of a class properties was wrapped into
#if DEBUG
public int SomeProperty { get; set; }
#endif
but the property usage was not. The publishing was done in Release configuration without the DEBUG symbol, obviously.