我在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文件中不正确的类之间的差异。但是,在这种情况下,没有差异,因为它是正确的文件。
编辑:我收到的一些错误消息: