Error “Metadata file '…\Release\project.dll

2019-01-10 08:20发布

Recently I started to get this message randomly:

Metadata file '...\Release\project.dll' could not be found in Visual Studio

I have a solution with several projects in it. The current build mode is Debug and all projects' configurations are set to Debug. But when I try to run the main project - sometimes it gives me a few errors, all of which are "Metadata file '...\Release\projectX.dll' could not be found" - and, look, it says about RELEASE folder, though current mode is Debug. Why? I tried to search for reference to "Release\projectX.dll" inside all solution files, and I found one in ResolveAssemblyReference.cache file.

I made a good search over the Internet and found a few people with a similar problem, but there was no solution, or at least no working solution.

I tried to delete references to those projects and read them, but in some time I start getting these errors again.

It seems like a bug. Why does it search for referenced projects in Release folders when I always use Debug mode?

PS. For those who met this problem: I couldn't solve it in an easy way. It disappeared only after I reinstalled Windows :(

30条回答
何必那么认真
2楼-- · 2019-01-10 09:12

I had this problem and took long while to figure it out. Problem came up when I removed projects from solution and replaced those with nuget packages.

Solution seemed to be fine but the .csproj file still contained those projects multiple times as reference.

Seems that VS does not clean that file appropriately. It was still referencing the removed projects under the hood. When manually removed the references from csproj file all works again! wohoo

查看更多
倾城 Initia
3楼-- · 2019-01-10 09:12

This problem is due to pdb files or CodeContracts.

To resolve it:

  1. Clean your output folder and rebuild the solution.

  2. Re-Configure the CodeContracts or disable it for temporary build.

查看更多
冷血范
4楼-- · 2019-01-10 09:12

We have that problem quite often, but only with references to C++/CLI projects from C# projects. It's obviously a bug deep down in Visual Studio that Microsoft decided not to fix, because it's 'too complex' and they promised an overhaul of the C++ build system which is now targeted for Visual Studio 2010.

That was some time ago, and maybe the fix even went into Visual Studio 2008; I didn't follow up on it any more. However, our typical workaround was

  • Switch configuration
  • Restart Visual Studio
  • Build the solution
查看更多
倾城 Initia
5楼-- · 2019-01-10 09:12

Sometimes VS2010 switches my configuration from Any CPU to Mixed Platforms. When this happens I get this error message.

To resolve it I switch back to Any CPU:
1. Right click on the solution and select properties.
2. Click on Configuration Properties and then the Configuration Manager... button.
3. Under Active solution platform select Any CPU

查看更多
我只想做你的唯一
6楼-- · 2019-01-10 09:13

Everyone is correct...try everything...(in order of a little to a lot of time wasted)

  1. Do you have bad code? Fix that first.
  2. Clean Solution & Restart Visual Studio
  3. Remove / Add References
  4. Check your build order w/ larger projects and verify
  5. Manually rebuild sub-projects
  6. Manually copy dlls between projects into associated bin folders
  7. Go get some coffee, play some pinball and come back tomorrow...you may think of something else in the meanwhile.
查看更多
走好不送
7楼-- · 2019-01-10 09:15

In my case, I had some errors in my code. Visual Studio showed the error you had instead of the actual errors, like syntax errors or unknown class names. Try cleaning the solution and building project after project. This way you will discover the actual errors.

Again, this is just what cause the error for me.

查看更多
登录 后发表回答