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:08

I seem to recall having a similar problem a few months ago. I solved it temporarily by copying the referenced DLL to the Release folder, thus satisfying Visual Studio's expectations. Later, I discovered the reference to the Release DLL in my actual code. You should try doing a search through the entire project for \release\project.dll.

Also, I have noticed that Visual Studio unit test projects sometimes put a "DeploymentItem" attribute on each of the test methods pointing to your target DLL, and if you switch between Debug and Release, Visual Studio can get confused if the DLL is no longer in the expected location. In my experience, these attributes can be safely deleted if you didn't put them there yourself as part of a "single deployment" scenario.

查看更多
看我几分像从前
3楼-- · 2019-01-10 09:09

I had the same problem. I noticed that my db context (EF4) that was located in the project dll wasn't recognize for some reason. I deleted it and created another one instead. and that solved it for me.

查看更多
你好瞎i
4楼-- · 2019-01-10 09:10

I've had this problem before and the only way I've found to solve it is to run Clean Solution and then restart Visual Studio.

查看更多
Root(大扎)
5楼-- · 2019-01-10 09:11

I had the same problem myself.

Visual Studio 2013 only told me that it couldn't reference to it, and it couldn't find the metadata. When I opened my solution (which has multiple projects in it) it said that I was using projects lower than the framework version of one of my projects.

So I switched everything to version 4.5, and it worked again.

查看更多
倾城 Initia
6楼-- · 2019-01-10 09:11

For me this was caused by the Build target having been rewritten to not output the dll. Removing this to fall back on the default Build target fixed the issue.

查看更多
老娘就宠你
7楼-- · 2019-01-10 09:12

For me it's usually the target framework being off (4.5.2 instead of 4.6) If you fix the target framework of the project to match the target framework of the solution and build, a new .dll will be created.

查看更多
登录 后发表回答