1
大約8年前,我已經被委託給一個用VB.NET/ASP.NET編寫的遺留網站添加一個web處理程序,使用.NET框架1.1.4322。WebHandler ASHX .NET編譯器錯誤:必須實現與ReadOnly/WriteOnly相匹配的IsReusable
我不明白爲什麼我收到此錯誤信息:
Compiler Error Message: BC30154: 'Foo' must implement 'Overridable ReadOnly Property IsReusable() as Boolean' for interface 'System.Web.IHttpHandler'. Implementing property must have matching 'ReadOnly/WriteOnly' specifiers
這裏是我的代碼:
<%@ WebHandler language="VB" class="Foo" %>
Imports System
Imports System.Web
Public Class Foo
Implements IHttpHandler
Public Sub ProcessRequest(context as HttpContext)
Implements IHttpHandler.ProcessRequest
'TO DO: Write request handling code here
End Sub
Public ReadOnly Property IsReusable() as Boolean
Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
我也試過ReadOnly Overrides Property IsReusable()
。
我認爲這是我的一個不同的愚蠢錯誤:'實現...'必須與Sub和Property聲明位於同一行,但位於類聲明下面的行。 – Tim
在VB中,如果你在下一行有相同的語句,你必須使用行爭用標記'_' – Jay