简体   繁体   中英

How do I resolve ambiguity between my project DLL and a DLL in the GAC?

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?

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.

我不确定,但也许你的答案在于你的配置的assemblyBinding标签: http//msdn.microsoft.com/en-us/library/twy1dw1e.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM