0

我在 Visual Studio 2010 中有一个 VB.Net 项目,旨在让用户上传视频,然后将其粘贴到数据库中。该文件称为“Media/Test.aspx.vb”。

当我尝试运行代码进行调试时,为名为 App_Web_nkhy2w0y.0.vb 的文件生成了大量错误

我在任何地方都找不到这个文件,而且我肯定没有写它,所以我双击错误,它打开了一个包含大约 350 行(显然)自动生成代码的文件,我不知道我在做什么确实导致它这样做。我也不知道如何解决它。

我承认我是 VB.Net 的新手,但我从未在网上看到过这样的事情,所以我一无所知。

下面是代码隐藏文件的原始代码,它只处理实际页面中的文件上传控件、按钮和标签。

Imports System.IO
Imports System.Data.SqlClient
Imports System.Data

Partial Class Media_Test

Inherits System.Web.UI.UserControl

Protected Sub TryMe_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TryMe.Click
    Dim connection As SqlConnection
    'check the file
    Dim buffer As Byte()

    If testFile.HasFile AndAlso testFile.PostedFile IsNot Nothing AndAlso testFile.PostedFile.FileName <> "" Then
        Dim file As HttpPostedFile = testFile.PostedFile
        'retrieve the HttpPostedFile object

        buffer = New Byte(file.ContentLength - 1) {}
        Dim bytesReaded As Integer = file.InputStream.Read(buffer, 0, testFile.PostedFile.ContentLength)
        'the HttpPostedFile has InputStream porperty (using System.IO;)
        'which can read the stream to the buffer object,
        'the first parameter is the array of bytes to store in,
        'the second parameter is the zero index (of specific byte)
        'where to start storing in the buffer,
        'the third parameter is the number of bytes 
        'you want to read (do u care about this?)

        If bytesReaded > 0 Then
            Try
                Dim connectionString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
                connection = New SqlConnection(connectionString)
                Dim cmd As New SqlCommand("INSERT INTO Videos (Video, Video_Name, Video_Size)" & " VALUES (@video, @videoName, @videoSize)", connection)
                cmd.Parameters.Add("@video", SqlDbType.VarBinary, buffer.Length).Value = buffer
                cmd.Parameters.Add("@videoName", SqlDbType.VarChar).Value = testFile.FileName
                cmd.Parameters.Add("@videoSize", SqlDbType.BigInt).Value = file.ContentLength
                Using connection
                    connection.Open()
                    Dim i As Integer = cmd.ExecuteNonQuery()
                    Label1.Text = "uploaded, " & i.ToString() & " rows affected"
                End Using
            Catch ex As Exception
                Label1.Text = ex.Message.ToString()
            End Try

        End If
    Else
        Label1.Text = "Choose a valid video file"
    End If
End Sub
End Class

生成页面的顶部是:

#ExternalChecksum("C:\Users\handcm\Documents\Visual Studio 2010\WebSites\APPS\Media\Test.aspx","{406ea660-64cf-4c82-b6f0-42d48172a799}","F31F20662F14B4894B6FBF58215628CB")
'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.296
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

如果需要,我可以发布整个文件,但是有人可以对这里发生的事情有所了解吗?我不知道如何调试我没有编写或从未见过的文件。

编辑 2:我检查了“'InitializeCulture' 不是 'ASP.media_test_aspx' 的成员”错误,它通常是 aspx 页面上继承的类与 aspx.vb 文件中的不正确的类之间的差异。但是,在这种情况下,没有差异,因为它是正确的文件。

编辑:我收到的一些错误消息:

  • 错误 4“GetWrappedFileDependencies”不是“ASP.media_test_aspx”的成员。C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\apps\f1b28c0f\bab8f810\App_Web_nkhy2w0y.0.vb 103
  • 错误 2 类“media_test_aspx”必须为接口“System.Web.IHttpHandler”实现“ReadOnly Property IsReusable As Boolean”。实现属性必须具有匹配的“ReadOnly”或“WriteOnly”说明符。C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\apps\f1b28c0f\bab8f810\App_Web_nkhy2w0y.0.vb 84
  • 错误 10“ProcessRequest”不是“Media_Test”的成员。C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\apps\f1b28c0f\bab8f810\App_Web_nkhy2w0y.0.vb 342
  • 错误 1“InitializeCulture”不是“ASP.media_test_aspx”的成员。C:\Users\handcm\Documents\Visual Studio 2010\WebSites\APPS\Media\Test.aspx 1
    我什至不知道最后一个是指什么,因为页面上肯定没有“初始化文化” .
4

0 回答 0