2009-02-11 97 views
24

短篇小说。 这个网站是由我的一个朋友创建的,他不知道那么多C#或asp。并且首先在VS 2k3中创建。当我把它转化为VS 2K8这些错误开始突然出现,也有与编制等问题,我设法理清(似乎被释放到VS 2K8想设计文件)解析器错误消息:文件'/TestSite/Default.aspx.cs'不存在

错误信息得到:

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 file '/TestSite/Default.aspx.cs' does not exist.

Source Error:

Line 1: <%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="GuildStats._Default" %>

Line 2:

Line 3: <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">

Defaults.aspx.cs

namespace GuildStats 
{ 
    public partial class _Default : System.Web.UI.Page 
    { 

Defaults.aspx

<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="GuildStats._Default" %> 

Site.master.cs

namespace GuildStats 
{ 
    public partial class Site : System.Web.UI.MasterPage { } 
} 

的Site.Master

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="GuildStats.Site" %> 

回答

72

Default.aspx变化CodeFileCodeBehind。您可能必须为Site.master做同样的事情。

请参见:CodeFile and Code-Behind

+0

该链接如何解决此问题?它提到了CodeFile属性,但没有提到CodeBehind。 MSDN文档声明CodeBehind已经过时,所以我试图找出为什么切换回CodeBehind是一个解决方案。 – 2009-10-16 17:49:59

12

网站项目中使用的CodeFile,Web应用程序项目使用代码隐藏。 CodeFile需要源文件,它在页面加载时被动态编译,CodeBehind需要编译代码。

我的猜测是,当您将项目类型从WebApp更改为Web站点或反之亦然时,就会创建您的问题。如果您这样做,您必须手动更改现有文件中的指令,新文件将自动具有正确的指令。