2012-05-26 89 views
-3

我在VS2010中運行asp.net,C#4.0應用程序。我得到以下編譯錯誤:我的代碼中編譯錯誤的原因是什麼

Server Error in '/' Application. 

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: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl). 

Source Error: 

Line 1: using System; 

Line 2: using System.Collections.Generic; 

Line 3: using System.Linq; 

我的頁面屬性是:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" 
    EnableEventValidation="false" Inherits="jsPlumb_jsPlumb_Default2" %> 

我的C#代碼隱藏類:

namespace CompanyDisplay.jsPlumb.jsPlumb.jsPlumb 
    { 
     public class jsPlumb_jsPlumb_Default2 : System.Web.UI.Page 
     { 
    } 
} 

我想命名空間來呈現運行一些Web服務應用程序。

+0

顯示你的代碼...爲了獲得更多的幫助。 – Rahul

+0

添加一些代碼來解釋您的問題。 –

+0

哪些代碼.cs代碼?它說錯誤在default.aspx.cs第1行:使用系統源文件:d:\ CompanyDisplay \ CompanyDisplay \ CompanyDisplay \ jsPlumb \ jsPlumb \ jsPlumb \ Default2.aspx.cs行:1 – jeni

回答

0

嘗試這樣做:在你的應用程序的web.config文件的編譯標記

  1. 加批=」假」如下圖所示

    編譯調試=」真正的」批=」假」

  2. 乾淨的解決方案

  3. 刪除臨時文件在Visual Studio小號的文件夾(它顯示了異常的文件夾)

  4. 做一個IISRESET和重建我的代碼再次

+1

並且可能重新安裝Windows?我不認爲你可以定義一個解決方案,無論如何理解問題 – Aristos

+0

- 爲什麼不呢?去嘗試一下! –

0

此錯誤時顯示的代碼隱藏類名稱不匹配在你的aspx頁面上「繼承」屬性。也許你試圖重新命名一些東西?

此外,我看到這個錯誤,當你試圖查看一個新頁面,但沒有編譯源代碼時,所以即使你的aspx存在,它也不能與相應的代碼隱藏類進行對抗。

編輯:

你有一個完全搞砸了命名約定,你在遇到問題要正確地匹配類的名字也不奇怪。

對不起,但這只是荒謬!

inherits="CompanyDisplay.jsPlumb.jsPlumb.jsPlumb.jsPlumb_jsPlumb_Default2" 

解決您的約定,也許你發現自己有這樣的源文件:

CodeBehind="Default.aspx.cs" Inherits="MyNamespace.jsPlumb.Default" 

不要做這樣jsPlumb.jsPlumb.jsPlumb ....這只是一個噩夢!

+0

@jeni,不要只是「嘗試」,這是一個非常簡單的事情。如果沒有幫助,向我們展示這些東西 - 您的aspx文件的PAGE屬性,代碼隱藏的類名和自動生成的代碼隱藏的類名。 (這些第一行開始像「公共類的東西:頁」) – walther

+0

我編輯我的問題,已添加頁面屬性和c#codebehind類..請參見 – jeni

0

我得到了ANSWER;我應該給繼承屬性作爲;

繼承= 「CompanyDisplay.jsPlumb.jsPlumb.jsPlumb.jsPlumb_jsPlumb_Default2」

+0

這裏添加命名空間的意義是什麼? – Aristos

+0

我們應該添加命名空間,以便aspx頁面將繼承cs頁面中的適當類別請參閱; http://forums.asp.net/t/941553.aspx/1 – jeni

+0

只有在使用同名,太多認爲,這是不好的設計。我有千分之一的頁面,從來沒有這個問題。 – Aristos

相關問題