尝试调试项目时出现不明确的 dll 解析器错误

发布于 2024-10-30 17:52:05 字数 717 浏览 2 评论 0原文

当我尝试调试 MVC 解决方案时,出现以下错误:


解析器错误 描述:解析服务此请求所需的资源时发生错误。请查看以下特定解析错误详细信息并适当修改您的源文件。

解析器错误消息:类型“HandiGamer.MvcApplication”不明确:它可能来自程序集“C:\Users\Kevin\documents\visual studio 2010\Projects\HandiGamer\HandiGamer\bin\HandiGamer.DLL”或来自程序集“C” :\Users\Kevin\documents\visual studio 2010\Projects\HandiGamer\HandiGamer\bin\HandiGamer.WebUI.DLL'。请在类型名称中明确指定程序集。

源错误:

第 1 行:<%@ Application Codebehind="Global.asax.cs" Inherits="HandiGamer.MvcApplication" Language="C#" %>

源文件:/global.asax 行:1


这是我第一次在我的项目中遇到此错误。自上次调试以来我所做的只是一个 .master 页、一个视图,并且我添加了几个 ViewModel 类。我的解决方案有两个项目 - HandiGamer.WebUI 和 HandiGamer.Domain - 但我以前从未遇到过它们的歧义问题。重建我的解决方案没有任何作用。我不知道还能做什么。

I'm getting the following error when I try to debug my MVC solution:


Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The type 'HandiGamer.MvcApplication' is ambiguous: it could come from assembly 'C:\Users\Kevin\documents\visual studio 2010\Projects\HandiGamer\HandiGamer\bin\HandiGamer.DLL' or from assembly 'C:\Users\Kevin\documents\visual studio 2010\Projects\HandiGamer\HandiGamer\bin\HandiGamer.WebUI.DLL'. Please specify the assembly explicitly in the type name.

Source Error:

Line 1: <%@ Application Codebehind="Global.asax.cs" Inherits="HandiGamer.MvcApplication" Language="C#" %>

Source File: /global.asax Line: 1


This is the first time I've encountered this error with my project. All I've changed since the last time I debugged it was a .master page, a view, and I added a couple ViewModel classes. My solution has two projects - HandiGamer.WebUI and HandiGamer.Domain - but I've never encountered an ambiguity issue with them before. Rebuilding my solution did nothing. I'm not sure what else to do.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雪化雨蝶 2024-11-06 17:52:05

您最近重命名了程序集吗?在这种情况下,旧的 DLL 可能仍在您的 bin 文件夹 ...\Projects\HandiGamer\HandiGamer\bin 中,并且正在运行时加载。正如错误消息所示,DLL

HandiGamer.DLL
HandiGamer.WebUI.DLL

都包含 HandiGamer.MvcApplication 因此解析器无法决定采用哪一个,并且当您尝试运行它时会发生冲突(编译通常工作正常,没有错误,问题通常是发生在运行时)。

要解决此问题,请手动从上面的 bin 文件夹中删除它们,然后重建整个解决方案。不幸的是,“清洁解决方案”并不总是能正确清理所有内容,因此有时您必须自己完成。


提示:如果卸载项目(在 Visual Studio 中:右键单击项目,然后选择“卸载...”),您可以随后在文本编辑器中编辑项目文件,然后搜索那里的程序集(为此,请再次右键单击已卸载的项目,然后选择“编辑...”)。

它包含您指定的所有参考文献 - 但要小心不要弄乱它。搜索并找到所需信息后,关闭它并重新加载项目。这通常比浏览项目参考部分中的所有条目要快得多。

Have you renamed you assembly recently? In this case it can be that the old DLL is still in your bin folder ...\Projects\HandiGamer\HandiGamer\bin and is being loaded on runtime. As the error message tells you, the DLLs

HandiGamer.DLL

HandiGamer.WebUI.DLL

both contain HandiGamer.MvcApplication so the parser cannot decide which of them to take and is getting a conflict when you try to run it (compiling usually works fine with no errors, the issue typically occurs during runtime).

To resolve this, delete them from the bin folder above manually, then rebuild the entire solution. Unfortunately, 'Clean Solution' does not always clean up everything correctly so you have to do it sometimes by yourself.


Hint: If you unload the project (in Visual Studio: right-click the project, then select "Unload..."), you can edit the project file afterwards in the text editor and then search for assemblies there (to do that, right-click again on the unloaded project, then select "Edit...").

It contains all the references you have specified - but be careful not to mess it up. After you have searched and found the information you were looking for, close it and re-load the project. This is usually much faster than going though all entries in the References section of your project.

挽心 2024-11-06 17:52:05

看起来 MvcApplication 类是在 HandiGamer 命名空间中的两个程序集中定义的。尝试使用 Reflector 打开它们,通过搜索此类名称来确认这一点。然后删除重复的类,仅将其保留在 ASP.NET MVC 应用程序程序集中。另一个项目必须是类库,而不是 Web 应用程序。

It looks like the MvcApplication class is defined in both assemblies in the HandiGamer namespace. Try opening them with Reflector to confirm this by searching for this class name. Then remove the duplicate class by leaving it only in your ASP.NET MVC application assembly. The other project must be a class library, not a web application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文