0

Visual Studio 2010 に VB.Net プロジェクトがあり、ユーザーがビデオをアップロードしてから DB に貼り付けることを目的としています。ファイルの名前は「Media/Test.aspx.vb」です。

コードを実行してデバッグしようとすると、App_Web_nkhy2w0y.0.vb というファイルに対して大量のエラーが生成されました。

私はこのファイルをどこにも見つけることができませんでしたし、私は確かにそれを書いていませんでした.これを行うようにしました。また、それを修正する方法もわかりません。

私は 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 プロパティ 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