如何在我的应用程序中修复以下错误
我目前正在维护一个使用Visual Basic开发的网站,我的问题是我正在维护或支持的这个Web应用程序出现以下错误。
错误38'DirList'不是'TigerBrandsIntranet.Lounge_Image_Library'的成员。 C:\ Users \Wise \Desktop \Tiger(Intranet)\BackUp of TBIntranet\TBIntranet\Lounge\Image Library.aspx.vb 111 9 TigerBrandsIntranet
这是给我提问的页面代码。
如果有人可以帮助解决这个错误,我会非常感激。 b $ b
I am currently maintaining a website that was developed using Visual Basic and my problem is that this web application I am currently maintaining or supporting has the following error.
Error 38 'DirList' is not a member of 'TigerBrandsIntranet.Lounge_Image_Library'. C:\Users\Wise\Desktop\Tiger(Intranet)\BackUp of TBIntranet\TBIntranet\Lounge\Image Library.aspx.vb 111 9 TigerBrandsIntranet
This is the code of the page that's giving me problems.
I would appreciate it so much if there's someone who can assist with this error.
Imports System.Drawing
Imports System.IO
Imports System.Drawing.Imaging
Partial Class Lounge_Image_Library
Inherits System.Web.UI.Page
Shared amsg As Label = New Label
Shared qmsg As Label = New Label
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
'Dim strStartPath As String
If Session("QuicklinksPath") = "" Then
Session("QuicklinksPath") = Server.MapPath("Image Library\")
End If
ListQuicklinks(Session("QuicklinksPath"))
If Session("ImagePath") = "" Then
Session("ImagePath") = Server.MapPath("Image Library\")
End If
If Request("imgdir") = "" Then
If Request("back") = "back" Then
If Session("strStartPath") = Session("ImagePath") Then
'do nor remove last dirname as we are at top level
Else
Dim spos, epos
epos = Len(Session("strStartPath"))
spos = InStrRev(Session("strStartPath"), "\", epos - 1)
Session("strStartPath") = Left(Session("strStartPath"), spos)
End If
Else
Session("strStartPath") = Server.MapPath("Image Library\")
End If
Else
If Request("menu") = "QM" Then
Session("strStartPath") = Session("ImagePath") & Request("imgdir") & "\"
Else
Session("strStartPath") = Session("strStartPath") & Request("imgdir") & "\"
End If
End If
ListFolder(Session("strStartPath"))
End Sub
Private Sub ListFolder(sFolderPath As String)
Dim DirNames, ilink As String
Dim cp
cp = 1
'start table
amsg.Font.Name = "Arial"
amsg.Font.Size = amsg.Font.Size.Small
amsg.Text = "<table width=100% cellspacing=4 cellpadding=4 >"
DirNames = Dir(sFolderPath, vbDirectory)
If Session("strStartPath") = Session("ImagePath") Then
Else
' write back
amsg.Text += "<tr><td colspan=2 >"
amsg.Text += "<a href=""Image Library.aspx?hdir=../&back=back"" style=""color:#000333;font-size:12px;text-decoration:none;""><<<<<< Back</a><br></td></tr>"
End If
Do While DirNames <> ""
If DirNames <> "." And DirNames <> ".." Then
If (GetAttr(sFolderPath & DirNames) And vbDirectory) = vbDirectory Then
'Session("strStartPath") = sFolderPath & DirNames
If cp = 1 Then
'begin new rol
amsg.Text += "<tr>"
'cp = cp + 1
End If
amsg.Text += "<td><a href=""Image Library.aspx?hdir=../&imgdir=" & DirNames & """ style=""color:#000333;font-size:12px;text-decoration:none;"">" & DirNames & "</a></td>" 'Print dir Folder Name
cp = cp + 1
Else
Dim image As System.Drawing.Image = System.Drawing.Image.FromFile(sFolderPath & DirNames)
Dim X As Integer = image.Width
Dim y As Integer = image.Height
Dim height As Integer = ((100 * y) / X)
Dim base64String As String
Using thumbnail As System.Drawing.Image = image.GetThumbnailImage(100, height, New System.Drawing.Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback), IntPtr.Zero)
Using memoryStream As New MemoryStream()
thumbnail.Save(memoryStream, ImageFormat.Png)
Dim bytes As [Byte]() = New [Byte](memoryStream.Length - 1) {}
memoryStream.Position = 0
memoryStream.Read(bytes, 0, CInt(bytes.Length))
base64String = Convert.ToBase64String(bytes, 0, bytes.Length)
End Using
End Using
ilink = sFolderPath & DirNames
ilink = Replace(ilink, Server.MapPath("Image Library\"), "")
ilink = Replace(ilink, "\", "/")
If cp = 1 Then
'begin new rol
amsg.Text += "<tr>"
'cp = cp + 1
End If
amsg.Text += "<td><a href=""Image Library/" & ilink & """ target=_blank style=""color:#000333;font-size:12px;text-decoration:none;""><img border=0 align=middle src=""data:image/png;base64," & base64String & """> " & DirNames & "</a></td>"
cp = cp + 1
End If
If cp = 3 Then
'close ro
amsg.Text += "</tr>"
cp = 1
End If
End If
DirNames = Dir()
Loop
'close table
amsg.Text += "</table>"
Me.DirList.Controls.Add(amsg)
End Sub
Private Sub ListQuicklinks(sFolderPath As String)
Dim DirNames As String
qmsg.Font.Name = "Arial"
qmsg.Font.Size = amsg.Font.Size.Small
qmsg.Text = ""
DirNames = Dir(sFolderPath, vbDirectory)
Do While DirNames <> ""
If DirNames <> "." And DirNames <> ".." Then
If (GetAttr(sFolderPath & DirNames) And vbDirectory) = vbDirectory Then
qmsg.Text += "<tr>"
qmsg.Text += "<td class=""style70""> </td>"
qmsg.Text += "<td style=""background-image: url('../../Images/Dots_Underline.gif'); background-repeat: repeat-x; background-position: center bottom; padding-left:5px; class=""style64"">"
qmsg.Text += "<a title=""Go to the " & DirNames & " Page"" class=""Text"" href=""Image Library.aspx?hdir=../&menu=QM&imgdir=" & DirNames & """ target=""_self"" style=""color:#666666;font-size:11px;text-decoration:none;"">" & DirNames & "</a></td>"
qmsg.Text += "<td style=""background-image: url('../../Images/Dots_Underline.gif'); background-repeat: repeat-x; background-position: center bottom; padding-left:5px; "" >></td>"
qmsg.Text += "<td > </td>"
qmsg.Text += "<td rowspan=""3""> </td>"
qmsg.Text += "</tr>"
Else
End If
End If
DirNames = Dir()
Loop
Me.QMenu.Controls.Add(qmsg)
End Sub
Public Shared Function GetFilesRecursive(ByVal initial As String) As List(Of String)
' This list stores the results.
Dim result As New List(Of String)
' This stack stores the directories to process.
Dim stack As New Stack(Of String)
' Add the initial directory
stack.Push(initial)
' Continue processing for each stacked directory
Do While (stack.Count > 0)
' Get top directory string
Dim dir As String = stack.Pop
amsg.Text += "<a href=""Image Library.aspx?hdir=../&imgdir=" & dir & """ style=""text-decoration:none;"">" & dir & "</a><br>"
Try
' Add all immediate file paths
result.AddRange(Directory.GetFiles(dir, "*.*"))
' Loop through all subdirectories and add them to the stack.
Dim directoryName As String
For Each directoryName In Directory.GetDirectories(dir)
stack.Push(directoryName)
Next
Catch ex As Exception
End Try
Loop
' Return the list
Return result
End Function
Public Function ThumbnailCallback() As Boolean
Return False
End Function
End Class
错误信息非常明显。如果你无法阅读和理解它,那么没有什么可以帮助你。这是你谁写了这个DirList
,没有其他人。此外,这个不存在的成员仅仅是之后的事实。
告诉我们你在自己的类中写了它,名为Lounge_Image_Library
。所以,那样你创建了一些类,试图使用一些名为DirList
的不存在的成员,你不需要在自己的类中创建。
因此,整个帖子看起来没有任何意义。问题很明显,很难想象你需要任何帮助来理解它。至于修复,这项任务是不可能或不可能的,它只是未定义,因为除了你之外没有人知道你的意图。更糟糕的是,如果你也不知道。-SA
The error message is quite obvious. If you cannot read and understand it, nothing can else help you. This is you who wrote thisDirList
, no one else. Moreover the mere fact that this non-existent member comes afterthis.
tells us that you wrote it in your own class calledLounge_Image_Library
. So, that way you who created some class, tried to use some non-existing member namedDirList
, which you did not bother to create in your own class.
So, it looks like the whole post makes no purpose. The problem is clear and apparent, so it's hard to imagine that you would need any help understanding it. As to the "fixing", this task is not possible or impossible, it is simply undefined, because no one except you knows your intent. Worse if you don't know it, too.—SA
它在该行Me.DirList.Controls.Add(amsg)
不是吗?
这意味着类Lounge_Image_Library
不包含名称为DirList
的成员。
我不知道它应该是什么类型,至少它必须有一个Controls集合。
由于代码片段状态Partial Class
我怀疑它可以在另一个代码文件中声明,而你的项目中缺少这个代码文件。
It is in the lineMe.DirList.Controls.Add(amsg)
isn't it?
This means that the classLounge_Image_Library
does not contain a member with the nameDirList
.
I do not know what type it is expected to be, at least it must have a Controls collection.
Since the code snippet statesPartial Class
I'd suspect that it could be declared in another code file, which is missing in your project.