2011-02-18 68 views
0

當我創建新的VS2008 asp.net應用程序,它建立良好。但是當我開始調試時,在瀏覽器中出現錯誤。我已經重建了應用程序。標記頁的Inherits子句與代碼隱藏C#中的類匹配。任何線索?解析器錯誤調試VS2008

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: Could not load type 'WebApplication3._Default'. 

Source Error: 


Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication3._Default" %> 
Line 2: 
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 


Source File: /Default.aspx Line: 1 


-------------------------------------------------------------------------------- 
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4927 

回答

1

嘗試從Inherits屬性移除命名空間:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" %> 
+0

哇,就是這樣。這怎麼可能?這是自動生成的與 – maatthias 2011-02-18 15:39:07

0

這通常是因爲代碼隱藏類名稱/命名空間發生了變化,但在.aspx頁面尚未更新(或反之亦然)。

您應該打開頁面背後的代碼,並確保命名空間和類名與您的.aspx頁中的內容匹配(並且該類標記爲公共)。

namespace WebApplication3 
{ 
    public class _Default 
    { 
     // ... 
+0

是的,他們匹配問題中提到的。我懷疑是一個腐敗vs安裝。 – maatthias 2011-02-18 15:37:37