views:

763

answers:

4

I have a project that references the System.Web.Mvc assembly in the GAC. I also have the ASP.NET MVC source code from Codeplex. I want to get a better understanding of the DefaultControllerFactory by stepping through its methods. How could I set this up?

Thanks!

A: 

If you have the pdb files you could add them and set a break point on certain functions.

http://www.aaronlerch.com/blog/2007/08/31/tip-set-breakpoints-without-source-code-in-visual-studio-2005/

Otherwise what may be easier since you might have to do this anyway to get some pdb's, is to download the source code from:

http://aspnet.codeplex.com/SourceControl/ListDownloadableCommits.aspx

And build and debug yourself, the source code may even illustrate what you want to know anyway.. or optionally use reflector:

http://www.red-gate.com/products/reflector/

Hope that helps.

meandmycode
Can't use the pdb, since it doesn't match the module in the assembly.
michielvoo
Yes, I did however explain you could download the source, and compile that which was much more likely.. aparently I didn't say it 'right'.
meandmycode
+3  A: 
  1. Compile the MVC code.
  2. Uninstall the MVC (To make sure you don't debug the retail bits)
  3. Use the assembly that you compiled, instead of the retail.
Shay Erlichmen
This is mostly right (upvoted), but you don't need to completely uninstall MVC. You can just remove it from the GAC and bin deploy your compiled assembly. Uninstalling would remove the tooling support, which you don't really want to do.
Craig Stuntz
When something is put in the GAC is has a dependency to something (File, Setup, etc) if that dependency exists (File still exits, setup not uninstalled) you cannot remove the assembly from the GAC.You can, however delete the file by finding is *real* path, but uninstall is simpler.
Shay Erlichmen
(Cont) but I think it is much simpler to uninstall, and install it once your done with it.
Shay Erlichmen
You can remove MVC from the GAC; we've done it (registry hack). Like I said, uninstall removes too much.
Craig Stuntz
Thanks, I didn't uninstall ASP.NET MVC, I just removed the reference to the GAC assembly and referenced the built assembly from the source. When I start debugging I have to select the source file and then it works.
michielvoo
Bonus question: I did this and it worked, but now I can't use third party assemblies that also reference ASP.NET MVC such as MVCContrib. I get error messages like this one:Error 1 The type 'System.Web.Mvc.HtmlHelper' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Any idea how I might be able to fix this? Thanks, Adrian
Adrian Grigore
Other then compile also MVCContrib or use this: http://www.codeproject.com/KB/security/StrongNameRemove20.aspx, I'm afraid that your pretty limited.
Shay Erlichmen
A: 

Your assemblies may be compiled in Release even if the Solution Configuratin drop down says Debug. It also may be that w3p.exe loaded your release assemblies.

1 -Use the Build->Configuration manager feature and make sure all of the project configurations are Debug. 2 - Build Clean 3 - Rebuild Solution 4 - iisreset (unloads Release assemblies if they're loaded) 5 - Invoke a page 6 - Attach process

hopefully the solid red circles show up now - best of luck

+1  A: 

If you do download the MVC source files from Codeplex, I've written a step by step guide on how to debug the System.Web.Mvc assembly, which you may find useful.

Steve Moss
Thanks for the link!
michielvoo