问题
I am currently working on another issue in my ASP.NET MVC project. In an effort to better understand what is happening in the codebase I decided to reference the ASP.NET MVC Source Code project in my own project by adding the solution file to my references.
When I did this, I started getting HTTP 404 errors.
It just so happens I had a breakpoint set on the OnException() method of the HandleErrorAttribute, otherwise it might have taken a long time to find the actual problem. When I hover over the filterContext parameter in the OnException method call, I get this Exception description:
The type 'System.Web.Mvc.ViewMasterPage' is ambiguous:
it could come from assembly [path to assembly in GAC]
or from assembly [path to assembly in my project]
The assembly in the GAC is there because I installed the ASP.NET MVC 2.0 RC2 release.
How do I best resolve this ambiguity?
回答1:
System.Web.Mvc is referenced in Web.Config, in the <Compilation><Assemblies> section. In my application, this entry has a public key token attribute.
I solved the problem by removing the PublicKeyToken attribute.
So this:
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
becomes this:
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral"/>
Apparently Visual Studio can't find the signed assembly in the GAC when the PublicKeyToken is missing, so it is forced to use the local project assembly.
回答2:
I am not sure but maybe your answer lies in the assemblyBinding tag of your config: http://msdn.microsoft.com/en-us/library/twy1dw1e.aspx
来源:https://stackoverflow.com/questions/2329830/how-do-i-resolve-ambiguity-between-my-project-dll-and-a-dll-in-the-gac