2012-07-13 80 views
0

建設ASP.net的網站時收到錯誤:ASP.net生成錯誤:標識符「__ASP」是不符合CLS

Identifier '__ASP' is not CLS-compliant

無處在我的代碼是有標識__ASP

i know why__ASP is not CLS-compliant (it starts with an _). What i need to figure out who is emitting it, and how either:

  • change it to not start with an underscore, or
  • make it private

i could also stop marking the assembly as CLSCompliant - but i'm not gonna

警告沒有列出任何有用的文件:

4d48b87d\63ccbbb9\App_Code.x0tl4q2v.49.cs line 15 

這是很明顯,不是一個文件我創建。我怎樣才能確定這個標識符的位置,並將其刪除,或將其設爲私有?


我是沒有遇到__ASP問題的唯一的人:

回答

1

的 「__ASP」 文件是由ASP.NET運行時編譯器創建將* .aspx,* .ascx,* .master文件轉換爲從您的CodeBehind類(或在MVC中,從您的ViewPage類派生)中的.NET類。編譯器構建系統還會在運行時編譯您的文件(而不是從IDE內部編譯它們)。

但是,除非已將[CLSCompliant]屬性添加到程序集的某處,否則不應在ASP.NET應用程序中獲得CLS兼容性消息。你有一個AssemblyInfo.cs文件,如果是的話,它在哪裏?

編輯:

我剛纔看到你說你的組件標記爲CLSCompliant。那麼,這是你的問題。你需要刪除它,因爲ASP.NET的批量編譯文件不符合要求:它們不需要。終端程序集(即沒有被其他程序集引用的終端程序集,通常是因爲它們是「應用程序」程序集)並不需要是CLSCompliant。

你爲什麼說「不會」刪除該屬性?沒有它是不合適的。

+0

共享代碼包含'CLSCompliant'屬性。如果網站沒有標記「CLSCompliant」屬性,則這些屬性會引發錯誤。但是我現在意識到,僅僅因爲我***擁有'[CLSCompliant]'屬性,它不會被*** ['CLSCompliant(true)]'。我將它改爲'[CLSCompliant(false)]',現在就可以使用。瞭解ASP.net本身不符合CLS(有助於證明禁用合規性)很有用。 – 2012-07-13 01:48:55