Reputation: 36443
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. Then I uncomment the usercontrols and everything is fine.
I have checked build orders and dependency 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.
Upvotes: 1000
Views: 1275345
Reputation: 6374
I was building a solution that contained several projects targeting different .NET versions, including 4.6.1. My errors looked something like this:
Metadata file '...Project1.dll' could not be found
Unable to find package ...Runtime.. Project1
Unable to find package ...Runtime.. Project2
NuGet.Cofing
.src
folder, which also must be in the root of your repo.Get-ChildItem -Path "src" -Recurse -Include @("bin", "obj") | Foreach-object {Remove-item -Recurse -path $_.FullName }
Upvotes: 0
Reputation: 185
Im running npm build of one project before the main build. When the npm build fails the main build doesnt build its references and then complains about missing .dll files and missing nuGet packages.
Upvotes: 0
Reputation: 1933
For me I checked the warnings not errors and noticed something wrong with one .dll in a bin folder.
I deleted that bin folder, Clean solution, Rebuild, all works now.
Upvotes: 0
Reputation: 401
In my case, it was an issue with my directory names.
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 one with valid characters resolved my issue. This can be done manually in the File Explorer. In my case, I just removed the %2c
s.
Upvotes: 30
Reputation: 33
The issue for me was that someone had copied the source project into the project, added a project reference to debug an issue and then re-added the NuGet package without removing the project reference!
This actuall built on some dev machines and failed on others, depending on if it tried to use the NuGet package or the project.
Manually editing the project files to delete the project references resolved the issue.
Upvotes: 0
Reputation: 169
This might also be caused by the fact that you have multiple projects in your solution but different projects target different versions of .net framework.
Upvotes: 0
Reputation: 284
Sometimes a local project is automatically referenced twice. Check your .csproj file for something like this and remove one line:
<ItemGroup>
<ProjectReference Include="..\ReferenceProject\ReferenceProject.csproj" />
<ProjectReference Include="..\ReferenceProject\ReferenceProject.csproj" />
</ItemGroup>
Upvotes: 1
Reputation: 306
In my case, I mistakenly wrote #endregion
twice. The problem was solved when I deleted one.
Upvotes: -1
Reputation: 161
Check that the project does not contain errors, otherwise the DLL cannot be generated
In my case, I had syntactic errors that were not visible from the Error List, when I checked the Output tab line by line I found some errors in the cshtml classes
Upvotes: 2
Reputation: 129
VS2022: Cause not found in the extensive listing already here.
Had a static class comprised entirely of static methods. Removing static from the class declaration didn't raise either a compile error or warning but did cause the OP build error.
Reverted the class declaration back to static and fixed the problem.
Upvotes: 1
Reputation: 519
For me it is still a "feature" in the current version of VS2022.
causes the error. Fix:
and a rebuild all succeeds without that metadata error
Upvotes: 4
Reputation: 1790
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.
Upvotes: 6
Reputation: 8651
I ran into this when doing a clean CLI rebuild of a MonoGame solution that had pure content projects.
The solution was to add a single dummy class file with an empty constructor to each of the content projects.
Upvotes: 0
Reputation: 115
Working with a Blazor WebAssembly ASP.NET Core hosted app, this problem arose when I deleted the WeatherForecast model and this caused a build error that wasn't visible as an error.
If this is the case for you, just remove the FetchData.razor file, and you'll be good to go!
Upvotes: 2
Reputation: 57
in my case: go to add references. in reference manager window uncheck dll project for other projects. save it. again add reference dll project to other projects.
Upvotes: 1
Reputation: 113
I'd faced the same problem. First i cleared all nuget cache from tools>Nuget Package Manager>Package Manager settings then click "Clear All Nuget Cache(s)". After this opened Powershell and run "dotnet restore" then "dotnet build". In my case this solution fixed my errors.
Upvotes: 2
Reputation: 47
I was facing the same issue with my project, I added console application in a solution but those other solution was not working and showing .dll not found, so I tried this method:
Upvotes: 0
Reputation: 12050
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.
Upvotes: 9
Reputation: 2321
In my case, I had a reference to another project which I deleted but I never used it in the code and therefore I didn't get any compilation errors.
Tip: Check if you have any references to other projects in your solution which do not exist.
Upvotes: 0
Reputation: 59
In Visual Studio 2019:
Upvotes: 2
Reputation: 3824
In my case the error message was as follows
Severity Code Description Project File Line Suppression State Error The command ""C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\gacutil.exe" /i "C:\Users\cmaggiul\source\repos\consume-evalue-api\EValueApi\EValueApi\bin\debug\EValueApi.dll"" exited with code 3. EValueApi
I followed the path to the EValueApi.dll file and realized that the debug directory was capitalized in Windows. I changed the directory to be lower case ( to match the location being used by gacutil.exe and it resolved my issue.
Upvotes: 0
Reputation: 5023
I'm using VS 2019. Our group is supposed to upgrade from 2017 to 2019.
I tried to clone to a folder on my C: drive that was part of my roaming profile (so on the network). I created a local folder that was guaranteed to be untracked and cloned there instead. The issues went away.
Notes:
Upvotes: 0
Reputation: 302
Nothing else here worked for me, but this did:
Now, suddenly VS pointed me to an error that wasn't showing up before. Furthermore, there were several errors in that one file that intellisense was ignoring. I corrected those without the help of red underlines and then was able to successfully build.
Upvotes: 0
Reputation: 137
The framework version of the current project differs from remaining projects. Change of framework version to existing projects version will resolve this.
Upvotes: 0
Reputation: 1911
I got the same error using Visual Studio 2019. After a closer look on what was going on in the background i found out there were errors on appended class libraries which in turn were not compiling correctly and throughing at the same time the error "Meta data file not found". Corrected the errors, compiled it again and all worked.
In my case the answer was found on analysis of the output tab.
Upvotes: 0
Reputation: 505
Navigate to Solution's Folder Explorer and delete the unused project folder that was throwing error. In my case, after deleting the project, the folder was still present in the directory. After deleting the folder solution built successfully!
Upvotes: 0
Reputation: 363
For me it was wrong folder name. If you close from source that replaces spaces with '%20', you will get such errors. Solution - just rename badly named folders.
Upvotes: 0
Reputation: 79
For me it was an unused import "using ApsNetCore" on a Controller. Removed it, clean, rebuild it and it worked.
Upvotes: 1
Reputation: 698
In VS 2019, under the project References check if there are any unresolved items by expanding Analyzers:
For me, there were two .dll
files with wrong paths. Right click on each and select Remove:
Build the project, then build the solution. Done.
Upvotes: 3
Reputation: 1455
I had a merge conflict in one .csproj file and ended up with two copies of one build target.
<Compile Include="SystemCodes\APSystemCodes.cs" />
After I eliminated the duplicate the build worked.
Upvotes: 0