Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

ASP.NET MVC and the GAAAK!

Yes, I know how it’s spelled. But "GAC" doesn’t fully demonstrate the wretching feeling I typically get when I’m dealing with it. So I’m trying my hand on some onomatopoeia.

I was recording a Dimecast this morning on S#arp Architecture because it’s an awesome piece of work. But one of the things it (currently) does with the VS template is create an MVC project. That is, a project explicitly linked to the MVC template. And if you don’t have that template installed, you get at least one error.

So I went about installing the MSI because I was also feeling some pain not having the various MVC item templates anyway. Tried the S@arp template again and all was well for the three hours it took me to record that ten minute webcast.

Then I switched over to the MVC project I’m working on. It uses an older version of MVC, around preview five-ish. Load up the site and an error appears indicating something like "Html.UrlAction doesn’t take 5 parameters" or "Exception: Maybe you ought to take up another line of work" or something. Clearly it is using the assemblies from the GAC rather than the bin directory like I told it.

The best option running through my head is to uninstall the assemblies from the GAC. I get to keep my templates but don’t have to deal with versioning issues. Unfortunately, as Phil notes, you can’t uninstall an assembly from the GAC if it was installed via MSI. Derik Whittaker says I could probably fix it by removing the MVC stuff from the web.config and re-adding it. Too hacky, says I.

My solution: whine to someone who can possibly solve my problem. In this case, the accommodating Billy McCafferty who assures me that S%arp will no longer have a hard dependency on the MVC templates in the near future. Which means I can uninstall MVC and go back to working with my various projects using different versions of the assemblies.

It’s temporary though. At the moment, I can’t open up the project I created with S~arp anymore. It gives an error: The project type is not supported by this application. (By the way, the solution to this is to open the .csproj file in a text editor and remove {603c0e0b-db56-11dc-be95-000d561079b0}; from the list of ProjectTypeGUIDs at the top.) In any case, S&arp isn’t the only project I’ve dealt with that is explicitly linked to the MVC templates.

I imagine in order to even get the templates to work, the assemblies it uses need to be somewhere relatively global. Whatever, all I know as a user is: I don’t want them in my GAC but I still want the project and item templates to work.

Final note: S*arp makes use of T4Toolbox to do some scaffolding. This project doesn’t appear to play well with VisualSVN if you happen to have it installed. The problem I believe is with T4Toolbox but don’t quote me. I had to uninstall VisualSVN to get the scaffolding to work. Seems related to similar issues with ActiveWriter.

Kyle the Versioned

This entry was posted in ASP.NET MVC, S#arp Architecture. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://dynamicprogrammer.com Hernan Garcia

    I totally agree, I personally prefer to use Spark as my view engine.
    I was reading the Sharp group as well.
    RC1 won’t use code behind, so we won’t even have to worry about any of this at all.

  • Kyle Baley

    Hernan, we are discussing something similar on the S~arp group. It seems when you remove the MVC GUID from the project types, you no longer get the Item Templates (like Add New View Content Page), even if you have MVC installed.

    Now, as you mention, it’s easy to create your own but by the same token, the View templates are basic enough that you don’t even need them. Most of the time, it’s as simple as changing the base type from Page to ViewPage. And very often, I don’t even need that. You can delete the code-behind file altogether and use the ViewPage base type as the code-behind file directly in your .aspx page. Assuming you remember the funky `[] CLR notation for generic types.

  • http://dynamicprogrammer.com Hernan Garcia

    I was trying to post this to the discussion group but I need to wait for approval and I’m very impatien :-)
    About losing the Item Templates for your MVC projects. You can easily create Item templates even if you don’t use ReSharper.
    Check this instructions: http://msdn.microsoft.com/en-us/library/tsyyf0yh(VS.80).aspx is really that simple.
    Hope this helps, H.

  • http://devlicio.us Billy McCafferty

    You seem to have an unfairly effective technique for moving things up on my priority list. 😉 The fix for this has been checked into the trunk and to the pre-packaged Visual Studio template at http://sharp-architecture.googlecode.com/svn/trunk/TemplatesAndCodeGen/VisualStudioTemplates/

  • Kyle Baley

    Dylan Beattie, you are an honorary hillbilly for that bit of goodness! Thanks!

  • http://dylanbeattie.blogspot.com/ Dylan Beattie

    Hi,

    It is possible – with a little tinkering – to remove ASP.NET MVC from the GAC whilst keeping the project templates installed. I’ve posted some notes on doing this at http://dylanbeattie.blogspot.com/2008/11/working-on-aspnet-mvc-beta-and-preview.html if you’re interested.