2009-02-11 102 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站點或反之亦然時,就會創建您的問題。如果您這樣做,您必須手動更改現有文件中的指令,新文件將自動具有正確的指令。