VS 2017 Metadata file '.dll could not be found

173,270

Solution 1

The problem was that I had some other normal error messages in my project, and apparently after I fixed those and when I cleaned and built my project AGAIN, then all .dlls succeeded.

Make sure you don't have any other error messages in your project and if you do, fix those first!

Solution 2

Steps in Fixing this Error: MetaData File .dll could not be found.

  1. Clean All Projects.

  2. Unload All Projects.

  3. Reload All Projects.

  4. ReBuild Solution.

Then problem solved.

Solution 3

In my case, there was an error, but it was not properly parsed out by VS and shown in the "Error List" window. To find it, you much view the ol "Output" from build window and parse through the messages starting from top down and resolve the actual error. M$, please fix! This is a huge waste of time of the worlds collective developers.

Solution 4

Double check the name of your project folder. In my case my project folder was named with spaces in it. When I cloned the project from Team Foundation Server using git bash the spaces in the folder name were converted to: "%20". Changing those back to spaces fixed the problem for me.

Solution 5

I had this issue with a solution containing multiple projects.

It came from duplicating a .csproj and adding the copy to the solution. A .csproj file contains a <ProjectGuid> element. I set the GUID of the copied project to a new one.

Update: Which GUID you use doesn't matter, it just needs to be different from the other project's GUID. You can create a new GUID from within Visual Studio: Tools -> Create GUID and copy the part between the curly brackets, i.e. {...}. Use that as the new value for the <ProjectGuid> element.

I also performed the following steps (not neccessarily neccessary, but they don't hurt):

  1. Close the solution
  2. Delete bin folder
  3. Delete all obj folders
  4. Open solution and build
Share:
173,270

Related videos on Youtube

Svenmarim
Author by

Svenmarim

Updated on February 27, 2021

Comments

  • Svenmarim
    Svenmarim about 3 years

    I know there is another question with exact the same problem, but I went trough all those answers, and none helped me. :( (This was the question.)

    I just created a new ASP.NET MVC project and joined a few '.dll's in the solution. Now when I try to build the project I get the error message shown below on 3 of the 5 libraries.

    Error   CS0006  Metadata file 'C:\Users\...\source\Database\bin\Debug\DataAccessLayer.dll' could not be found   Logic   C:\Users\...\source\Logic\CSC   1   Active
    
    Error   CS0006  Metadata file 'C:\Users\...\source\Logic\bin\Debug\Logic.dll' could not be found    PTS2-MVC    C:\Users\...\source\PTS2-MVC\CSC    1   Active
    
    Error   CS0006  Metadata file 'C:\Users\...\source\PTS2-MVC\bin\PTS2-MVC.dll' could not be found    PTS2-MVC.Tests  C:\Users\...\source\PTS2-MVC.Tests\CSC  1   Active
    

    When I go to the bin\debug folder of that .dll, I see that it is empty, and the other .dll where I do not get an error message, is not empty. But I am clueless how to fix this or what I did to make this happen.

    The most common answer is to go to the properties of the solution and go to configuration and uncheck -> apply -> check and apply again, but that didn't work

    • TheNoob
      TheNoob almost 7 years
      Just a guess, but it seems like VS cleaned those out. Im not sure what those dlls are or where they are from, but if you're the one that made them I'd make sure whatever solution they are in built them. If these folders are from what your current solution is building to then it wont find these once you clean your solution again.
    • Asif Raza
      Asif Raza almost 7 years
      Clean ^ rebuild || restart your visual , check again
    • Svenmarim
      Svenmarim almost 7 years
      @AsifRaza I litterly did that already so many times, but thinking with me :)
    • Svenmarim
      Svenmarim almost 7 years
      @TheNoob So you say i need to try and clean my solution and then build it? because i already tried that
    • Asif Raza
      Asif Raza almost 7 years
      delete the all the from bin folder , then rebuild ^ check
    • Shanmukhi Goli
      Shanmukhi Goli almost 6 years
      That issue mostly comes when you other build errors in any of the code files. Look at the output window for any errors not listed in the "Error List" window. This will give you a clue.
    • robs
      robs over 5 years
      The suggested fix of solution property pages->Configuration then uncheck 'Build' for all projects, Apply and then recheck and Apply again fixed the problem for me. I started receiving two extra errors which were the source of the problem but not previously showing. Once they were fixed everything compiled.
    • camelCase
      camelCase about 2 years
      This question Q& A thread lead to me solving my variation of the Metadata file problem. Unfortunately I will have to post my fix details in the much older alternative mentioned in the duplicate closure message above.
  • jbyrd
    jbyrd over 6 years
    I actually had the same issue, but had no other Errors showing up, only the 1 error about the missing .dll. But then at some point (without me changing any code), suddenly a syntax error showed up that wasn't showing up before. Once I fixed that error, then like you said, I cleaned, rebuilt, and everything worked.
  • Santosh
    Santosh about 6 years
    Same issue here. There seems to be a bug in the Error List window where errors don't show up sometimes (and other times errors which were fixed continue to show up, despite doing a clean/rebuild). The Output window is more reliable so check there when you run into this issue.
  • Arsen Khachaturyan
    Arsen Khachaturyan about 6 years
    The same problem, because of STUPID VSTS.
  • user1431072
    user1431072 about 6 years
    I found that I had to enable warnings in my "error list" tab in visual studio. It was in the warnings that I saw that a referenced .dll could not be resolved. I had to remove the existing reference and add a new one in the correct directory. All is well now.
  • robs
    robs over 5 years
    see my comment above, but basically same thing except some bug in VS was stopping the errors from showing until I unchecked/checked the Build options in the Solution property pages.
  • BlueStrat
    BlueStrat over 5 years
    Closing Visual Studio (20127), then deleting .svn folder from solution folder did the trick for me.
  • Alain Elemia
    Alain Elemia over 5 years
    I changed directories of my projects causing problem with dll's not building using rebuild all and this answer fixes my problem.
  • canbax
    canbax over 5 years
    This should not be the answer 'cuz it is the most obvious thing that could happen. For me the solution was a DLL path was hard coded and it was missing
  • Svenmarim
    Svenmarim over 5 years
    @canbax, good for you that you found your own solution, but you can't say that this should not be an answer. Because apparently alot of people (including my self) forget this "obvious" answer. Alot of problems in SE are "obvious" problems, but it can still take hours before you finally figure out the issue.
  • Ishwor Khanal
    Ishwor Khanal over 5 years
    It was aspboilerplate architecure that I was working on and suddenly unexpected error happened and then started playing up that .dll was not found but it was the problem of other error as @Svenmarim mentioned in his answer. Thank you.
  • user3785553
    user3785553 almost 5 years
    This was the exact reason for the above error. Thanks for the tip. it worked
  • Wojtek Turowicz
    Wojtek Turowicz almost 5 years
    Same here, but I had %20 in the folder name.
  • Vu Nguyen
    Vu Nguyen over 4 years
    This really fixed my case.
  • Calum Mullen
    Calum Mullen about 4 years
    This resolved the issue for me. Tried all other solutions, but the output window pointed me to my project being built against netframework 4.7.2, which was higher than the targeted framework netframework 4.6. Just had to edit the .csjproj to point at 4.6.
  • Anthony Queen
    Anthony Queen about 4 years
    So, while it wasn't showing up as an error, there was a non-error blurb in the output window that keyed me in. I had references to a couple of .NET 4.6.1 assemblies, but my project was .NET 4.5. Make sure all your projects are at the correct .NET framework version.
  • Anthony Queen
    Anthony Queen about 4 years
    Same thing here.
  • TyngeOfTheGinge
    TyngeOfTheGinge about 4 years
    This was absolutely the answer for me. Fix one "normal" error and all of those other dll errors went away.
  • James L.
    James L. almost 4 years
    My error was that I had an existing variable name as the name used inside a query :: var wr = _repo.Query<WorkRequest>().Where(wr=> wr.Id == wrId).First();. I fixed it by changing the inner variable to WR instead. For some reason this build error is only visible in the output window :/
  • ikariw
    ikariw almost 4 years
    unloading and re-loading were the key for me. i spent a long time on this issue until doing that!
  • Banana Cake
    Banana Cake almost 4 years
    Same problem. The error didnt show in the error list, but after closing and reopenning VS, it showed the specific error.
  • ɐsɹǝʌ ǝɔıʌ
    ɐsɹǝʌ ǝɔıʌ over 3 years
    This is the only answer that really helped me. Superb! Thanks!
  • Lasithe
    Lasithe over 3 years
    This was my solution
  • Heri
    Heri over 3 years
    The same in VS 2019: Just closing VS and re-opening the solution helped.
  • Masoud
    Masoud over 3 years
    Thank you, after 5 hours searching & trying, your solution saved me:)
  • CipherShark
    CipherShark about 3 years
    This worked for me - nothing else did.
  • questions
    questions about 2 years
    this was it for me too, but my project was on azure devops