visual-studio 错误“在 Visual Studio 中找不到元数据文件 '...\Release\project.dll'”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/898559/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error "Metadata file '...\Release\project.dll' could not be found in Visual Studio"
提问by nightcoder
Recently I started to get this message randomly:
最近我开始随机收到这条消息:
Metadata file '...\Release\project.dll' could not be found in Visual Studio
在 Visual Studio 中找不到元数据文件“...\Release\project.dll”
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.
我有一个包含多个项目的解决方案。当前构建模式为Debug,所有项目的配置都设置为Debug。但是当我尝试运行主项目时 - 有时它会给我一些错误,所有这些都是“找不到元数据文件'...\Release\projectX.dll'” - 而且,看,它说的是 RELEASE文件夹,虽然当前模式是调试。为什么?我试图在所有解决方案文件中搜索对“Release\projectX.dll”的引用,我在 ResolveAssemblyReference.cache 文件中找到了一个。
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?
这似乎是一个错误。当我总是使用调试模式时,为什么它会在 Release 文件夹中搜索引用的项目?
PS.For those who met this problem: I couldn't solve it in an easy way. It disappeared only after I reinstalled Windows :(
附注。对于遇到此问题的人:我无法以简单的方式解决它。只有在我重新安装 Windows 后它才消失:(
回答by beauXjames
Everyone is correct...try everything...(in order of a little to a lot of time wasted)
每个人都是正确的......尝试一切......(以浪费一点到很多时间的顺序)
- Do you have bad code? Fix that first.
- Clean Solution & Restart Visual Studio
- Remove / Add References
- Check your build order w/ larger projects and verify
- Manually rebuild sub-projects
- Manually copy dlls between projects into associated bin folders
- Go get some coffee, play some pinball and come back tomorrow...you may think of something else in the meanwhile.
- 你有错误的代码吗?先解决这个问题。
- 清理解决方案并重新启动 Visual Studio
- 删除/添加引用
- 使用较大的项目检查您的构建顺序并验证
- 手动重建子项目
- 手动将项目之间的 dll 复制到关联的 bin 文件夹中
- 去喝杯咖啡,打弹球,明天再来……在此期间你可能会想到别的事情。
回答by dapim
I had the exact same problem. Big visual studio solution with 50+ projects.
我有同样的问题。包含 50 多个项目的大型视觉工作室解决方案。
All references were added as projects. Project build order was correct (right click on project and select build order).
所有引用都作为项目添加。项目构建顺序正确(右键单击项目并选择构建顺序)。
However when building some of the higher level projects the "root" project they depended on were not built.
然而,在构建一些更高级别的项目时,它们所依赖的“根”项目并未构建。
The problem was that these projects were not selected to build under the current configuration (don't know how this happened).
问题是这些项目没有选择在当前配置下构建(不知道这是怎么发生的)。
To check this select "Configuration Manager" (Build menu) e check if the problematic projects are set to build.
要检查此项,请选择“配置管理器”(构建菜单) e 检查是否将有问题的项目设置为构建。
回答by Darren Steinweg
When you say you deleted references to those projects and re-added them, how did you re-add them, exactly? Did you use the "Browse" tab in the "Add Reference" dialog in Visual Studio? Or, did you use the "Projects" tab (which lists neighboring projects in your solution)?
当您说您删除了对这些项目的引用并重新添加它们时,您究竟是如何重新添加它们的?您是否使用了 Visual Studio 中“添加引用”对话框中的“浏览”选项卡?或者,您是否使用了“项目”选项卡(其中列出了解决方案中的相邻项目)?
Edit: If you use the "Browse" tab, and manually add the reference to your .dll that is located in the /Release folder, then Visual Studio will always look for the .dll in that location, regardless of what mode you're currently in (Debug or Release).
编辑:如果您使用“浏览”选项卡,并手动添加对位于 /Release 文件夹中的 .dll 的引用,则 Visual Studio 将始终在该位置查找 .dll,无论您处于何种模式当前处于(调试或发布)中。
If you removed the actual .dll file from the Release folder (either manually or by doing "Clean Solution"), then your reference will break because the .dll does not exist.
如果您从 Release 文件夹中删除了实际的 .dll 文件(手动或通过执行“清理解决方案”),那么您的引用将中断,因为 .dll 不存在。
I'd suggest removing the reference to ProjectX.dll, and add it in again--but this time, use the "Projects" tab in the "Add Reference" dialog. When you add a reference this way, Visual Studio knows where to get the appropriate .dll. If you're in Debug mode, it will get it from the /Debug folder. If in Release mode, the /Release folder. Your build error should go away, and you also will no longer be (improperly) referencing a Release .dll while in Debug mode.
我建议删除对 ProjectX.dll 的引用,然后再次添加它——但这一次,使用“添加引用”对话框中的“项目”选项卡。当您以这种方式添加引用时,Visual Studio 知道从何处获取适当的 .dll。如果您处于调试模式,它将从 /Debug 文件夹中获取它。如果处于发布模式,则为 /Release 文件夹。您的构建错误应该会消失,并且您在调试模式下也将不再(不正确地)引用 Release .dll。
回答by Vikram
Well, my answer is not just the summary of all the solutions, but it offers more than that.
嗯,我的回答不仅仅是所有解决方案的总结,但它提供的不仅仅是这些。
Section (1):
第 (1) 节:
In general solutions:
一般解决方案:
I had 4 errors of this kind (‘metadata file could not be found') along with 1 error saying 'Source File Could Not Be Opened (‘Unspecified error ‘)'.
我有 4 个此类错误(“找不到元数据文件”)以及 1 个错误,提示“无法打开源文件(“未指定的错误”)”。
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 VS 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 2 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.
重新启动 VS 并再次尝试构建。
转到“解决方案资源管理器”。右键单击解决方案。转到属性。转到“配置管理器”。检查“构建”下的复选框是否被选中。如果其中任何一个或全部未选中,请检查它们并再次尝试构建。
如果上述解决方案不起作用,则按照上面步骤 2 中提到的顺序,即使选中了所有复选框,也取消选中它们,再次检查并再次尝试构建。
构建顺序和项目依赖项:
转到“解决方案资源管理器”。右键单击解决方案。转到“项目依赖项...”。您将看到 2 个选项卡:'Dependencies'和'Build Order'。此构建顺序是构建解决方案的顺序。检查项目依赖项和构建顺序,以验证依赖于其他项目(比如“project2”)的某个项目(比如“project1”)是否在该项目(比如“project2”)之前尝试构建。这可能是导致错误的原因。
检查丢失的 .dll 的路径:
检查丢失的 .dll 的路径。如果路径包含空格或任何其他无效的路径字符,请将其删除并再次尝试构建。
如果这是原因,则调整构建顺序。
Section (2):
第 (2) 节:
My particular case:
我的特殊情况:
I tried all the steps above with various permutations and combinations with restarting VS few times. But, it did not help me.
我用各种排列组合尝试了上述所有步骤,并重新启动 VS 几次。但是,它对我没有帮助。
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: http://www.anujvarma.com/tfs-errorsource-file-could-not-be-opened-unspecified-error/#comment-1539
我遇到了一个博客:http: //www.anujvarma.com/tfs-errorsource-file-could-not-be-opened-unspecified-error/#comment-1539
I tried the steps mentioned in that blog 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):
第 (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.
尝试上面第 (1) 节中提到的所有解决方案(以及任何其他解决方案)以消除错误。如果没有任何效果,请按照上面第 (2) 节中提到的博客,从 .csproj 文件中删除源代码管理和文件系统中不再存在的所有源文件的条目。
回答by jasonh
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.
我以前遇到过这个问题,我发现解决它的唯一方法是运行 Clean Solution,然后重新启动 Visual Studio。
回答by Adam Weitzman
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.
对我来说,通常是目标框架关闭(4.5.2 而不是 4.6)如果您修复项目的目标框架以匹配解决方案的目标框架并构建,将创建一个新的 .dll。
回答by Sebastian Patten
Re-open Visual Studio as Administrator.
以管理员身份重新打开 Visual Studio。
回答by Totonga
Did you check the Configuration manager settings? In the project settings dialog top right corner.
您是否检查了配置管理器设置?在项目设置对话框右上角。
Sometimes it happens that between all the release entries a debug entry comes in. If so, the auto dependency created by the dependency graph of the solution gets all confused.
有时,在所有发布条目之间会出现一个调试条目。如果是这样,解决方案的依赖关系图创建的自动依赖就会变得混乱。
回答by Oscar Canek
Most of the answares say that you need to remove the libraries of your solution, this is true but when you re-add the libraries the error will be shown again. You need to verify if all the libraries referenced have a compatible .net framework with the .net framework of your solution.Then fix all the errors in your code and rebuild the solution.
大多数 answares 说您需要删除解决方案的库,这是真的,但是当您重新添加库时,错误将再次显示。您需要验证所引用的所有库是否都具有与解决方案的 .net 框架兼容的 .net 框架。然后修复代码中的所有错误并重建解决方案。
回答by Anthony Collins
We recently ran into this issue after upgrading to Office 2010 from Office 2007 - we had to manually change references in our project to version 14 of the Office Interops we use in some projects.
我们最近在从 Office 2007 升级到 Office 2010 后遇到了这个问题 - 我们不得不手动将项目中的引用更改为我们在某些项目中使用的 Office Interops 版本 14。
Hope that helps - took us a few days to figure it out.
希望有所帮助 - 我们花了几天时间才弄明白。

