ASP.NET MVC 1.0 - 1. 准备工作

来源:互联网 发布:java项目名命名方法 编辑:程序博客网 时间:2024/05/24 15:36

除了下载相应的安装文件和源代码外,我们还得做些额外的事情才能开始分析工作。

1. Add System.Web.Mvc Project Reference

将创建的 MVC Project 对 GAC System.Web.Mvc.dll 引用改成 MVC 源代码项目引用。

2. Web.config

注释掉 Web.config 中对 System.Web.Mvc 的默认配置。

<compilation debug="true">
<assemblies>
<!--<add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>-->
</assemblies>
</compilation>


如果没有做这个步骤,那么恭喜你,你会看到如下的错误界面。

uploads/200903/14_095433_snap1.png

 

Server Error in '/' Application.
--------------------------------------------------------------------------------

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The type 'System.Web.Mvc.ViewMasterPage' is ambiguous: it could come from assembly 'D:/System/My Documents/Visual Studio 2008/Projects/.../bin/System.Web.Mvc.DLL' or from assembly 'C:/WINDOWS/assembly/GAC_MSIL/System.Web.Mvc/1.0.0.0__31bf3856ad364e35/System.Web.Mvc.dll'. Please specify the assembly explicitly in the type name.

Source Error:

Line 1: <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>


3. Views/Web.config

删除所有 "Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35",因为我们用源代码编译的 System.Web.Mvc.dll 没有签名文件。

省略该步骤,会导致泛型 ViewPage<TModel>.Model 不泛型。

原创粉丝点击