views:

52

answers:

2

I've been trying to set up the ASP.NET MVC 2 RTM Source for use with my app, so I can step through things like model binding when debugging. However, I haven't been able to get it to work - I'm getting errors like:

The type 'System.Web.Mvc.Controller' is defined in an assembly that is not referenced. 
You must add a reference to assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'.

The type 'System.Web.Mvc.Async.AsyncControllerActionInvoker' is defined in an assembly that is not referenced. 
You must add a reference to assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35'.

Etc...

I followed the steps in Steve Sanderson's howto (for MVC1), but perhaps there are different steps to get it to work in MVC2?

Steps I have taken so far:

  • Removed references to GAC based System.Web.Mvc dll from all of my projects.
  • Added the MVC source as a project in the solution.
  • Added references to the System.Web.Mvc project in each of my projects.
  • Commented out the <add assembly="System.Web.Mvc... item in the <compilation><assemblies> section of the root web.config
  • Commented out the <add assembly="System.Web.Mvc... item in the section of the web.config in the Views folder (and the Views folders of each of the areas)
  • Find/replaced any of the references to System.Web.Mvc, Version=2.0.0.0 and replaced their PublicKeyToken value with null (was 31bf3856ad364e35)

So, questions:

  • has anyone else got this working? (presumably yes!)
  • Where are the PublicKeyToken numbers coming from in the errors?
  • There are some other references to this same PublicKeyToken (31bf3856ad364e35) for other dlls in the web.config (e.g. System.Web.Extensions) is this relevant?
  • Any idea what I'm doing wrong?! Steps I've missed?

Thank you!

UPDATE: In response to Syd's questions, here's some extra info:

1) Current assemblies node from web.config:

<compilation debug="true">
    <assemblies>
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    </assemblies>
</compilation>

2) Yes, I am using MVC Futures, but have that project built in my solution too, and have referenced it to use the System.Web.Mvc in the solution.

3) I am using a few non-standard references. Rather that a screenshot I'll list them here:

Autofac
Autofac.Integration.Web
Autofac.Integration.Web.Mvc
Elmah
FluentValidation
FluentValidation.Mvc
log4net
MvcContrib
MySql.Data
NHibernate
MvcFutures
+1  A: 

Instead of commenting out the <assemblies><add assembly> lines, you should set the PublicKeyToken=null instead.

Syd
Ok, just tried this and still get the same errors I'm afraid.
UpTheCreek
More questions. 1) Can you list your modified lines in the "assemblies" node? 2) Can you do a screen capture of the References in your project? 3) Also are you using the MVC futures?
Syd
Thanks, I've updated the question with the info you requested :)
UpTheCreek
Your other DLLs (e.g. Autofac and FluentValidation) may be dependent on the released version of Mvc. Please try bindingRedirect - See http://msdn.microsoft.com/en-us/library/eftw1fys.aspx
Syd
+1  A: 

You don't need to download the source code or remove references from the GAC. Just follow the steps described in this blog post.

  • Uncheck: Enable Just My Code (Managed only)
  • Check: Enable source server support
  • Add symbols server: In VS2010 you only need to check the Microsoft Symbols Servers, no need to enter url, in VS2008 you need to enter the url

Create a new ASP.NET MVC application, put a breakpoint in your controller action and when the breakpoint gets hit, load the symbols for the System.Web.Mvc assembly from the call stack and once the symbols are loaded you will be able to step through the source code (after accepting the terms and conditions).

Darin Dimitrov
Yeah, I would have preferred doing it that way, but my current draconian network setup means eternal source servers are not an option. This might be the way I have to go eventually though if I can't get the source working.
UpTheCreek
Meant 'external', not 'eternal' in that previous comment of course ;)
UpTheCreek