views:

144

answers:

2

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

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

AaronLS
System.Web.Mvc is not referenced in AssemblyBinding, but it *is* referenced in Compilation/Assemblies. I think I solved it. Thanks for the assist. +1
Robert Harvey
+1  A: 

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.

Robert Harvey