www.codinghillbilly.com   kyle.baley.org  Subscribe / Contact
 
 
 
 
LATEST POSTS
Sunday, March 01, 2009

This post is here for informational purposes only and is meant to be hit by users searching for a specific error. If you are reading this in your RSS reader, I apologize in advance for forcing you to read this far.

The context: An MVC application using what I believe is RC1 of ASP.NET MVC and Sharp Architecture.

The error:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0433: The type 'System.Web.Mvc.ViewPage<HoochBase>' exists in both 'c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\GrowOpMgr\9ce51819\6bc1e534\assembly\dl3\e30b5990\f8ba0707_929ac901\GrowOpMgr.Web.DLL' and 'c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\GrowOpMgr\9ce51819\6bc1e534\assembly\dl3\27c4ec24\01860e2f_d595c901\System.Web.Mvc.DLL'
Source Error:

Line 170:    
Line 171:    [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 172:    public class views_hooches_index_aspx : System.Web.Mvc.ViewPage<IEnumerable<HoochDto>>, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler {
Line 173:        
Line 174:        private static bool @__initialized;

Source File: c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\GrowOpMgr\9ce51819\6bc1e534\App_Web_index.aspx.9399a72b.8jtr0zsp.0.cs    Line: 172

 

The cause

I had created a view page without the aid of the MVC templates. I.e. I added a regular Web Form and manually changed the Inherits attribute in the Page directive at the top to System.Web.Mvc.ViewPage<HoochBase> like so (notice I also deleted the CodeBehind and AutoEventWireup attributes):

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<HoochBase>" %>

That is, I want to derive from the ViewPage<T> class, not from the code-behind. But I forgot to delete the code-behind files that were created by the Web Form template. I can only guess at what’s happening behind the scenes.

Note that if you do the same, this compilation error will occur on every MVC-based page, not just the one you created.

I imagine this doesn’t occur when you create an MVC View Page directly from the Add New Item dialog but I don’t have those templates. Installing them requires one of the following:

  • Running the msi package for MVC
  • Extracting the templates from the msi package and installing them manually

I don’t want to do the first because it installs MVC in the GAC which I absolutely do not want given the number of MVC apps I have lying around my machine using various versions of the framework. As for the second, I’m lazy, okay? YOU’RE NOT MY MOTHE---actually, I probably shouldn’t make that claim…

Would be nice if the MVC templates for creating view pages and view user controls were available outside of the .msi but it’s not hard to create pages/user controls without them.

Except when you get compilation errors, I suppose.

Kyle the Runtimed

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Copyright © 2010 Kyle Baley. All rights reserved.
 
CATEGORIES
.NET General (18) alt.net (4) altnetconf (9) ASP.NET AJAX (40) ASP.NET MVC (29) Bahamas (1) Bahanet (9) BDD (1) Brownfield (21) Career (10) Castle (1) Code coverage (1) Code review (2) Coding Style (6) Communication (1) Community (18) Conscientious Coding (35) Continuous Integration (11) dasBlog (12) Development (16) DevTeach (4) Domain (2) Environment (4) Estimating (1) Featured (14) Flamingo (10) Games (1) Google App Engine (3) GWT (9) Hardware (6) Java (2) Javascript (7) Linq (2) Livelink (6) Lucene.NET (2) MbUnit (1) Metrics (2) Miscellaneous (25) Mocking (4) NAnt (4) NHibernate (12) NInject (1) Office (3) Office Development (6) Open Rasta (1) Patterns (6) Presenting (14) Professional Development (15) Refactoring (10) ReSharper (11) REST (3) S#arp Architecture (5) Security (3) Software (11) Sundry (19) TDD (19) Tools (22) User Interface (6) Utilities (9) Visual Studio (8) VSTO (1) Web development (12) Windows (3) Working Remotely (17) Workplace (3) Writing (6)
 
LATEST POSTS
 
POPULAR POSTS
 
 
ARCHIVE