程序将以调试模式运行,但一旦发布就不会运行

时间:2013-03-13 23:28:57

标签: vb.net visual-studio

出于某种原因,我现在在VB 2010中尝试制作的任何程序都将在Visual Basic的调试模式下运行,但是一旦我在计算机上发布它就不会运行,任何有关这方面的帮助都将不胜感激。

代码以备不时之需。

主要表格:

Public Class Form1
Dim locat As String = System.Reflection.Assembly.GetEntryAssembly.Location
Dim MyDirectory As String = System.IO.Path.GetDirectoryName(locat)

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim sfile As String
    Dim rfile As String
    sfile = IO.Directory.GetCurrentDirectory + "\Games\" + ListBox1.SelectedItem.ToString
    rfile = ListBox1.SelectedItem.ToString
    My.Computer.FileSystem.DeleteFile(sfile)
    ListBox1.Items.Remove(rfile)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    Dim ddir As String
    ddir = My.Computer.FileSystem.CurrentDirectory + "\Games\"
    ListBox1.Items.Clear()
    My.Computer.FileSystem.DeleteDirectory(ddir, FileIO.DeleteDirectoryOption.DeleteAllContents)
    My.Computer.FileSystem.CreateDirectory(Application.StartupPath & "\Games\")
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If IO.File.Exists(MyDirectory + "\" + Me.ProductName + ".old") Then
        IO.File.Delete(MyDirectory + "\" + Me.ProductName + ".old")
    End If

    Dim dir As New IO.DirectoryInfo(Application.StartupPath & "/Games/")
    Dim files As IO.FileInfo() = dir.GetFiles("*.swf")
    Dim fileName As IO.FileInfo
    For Each fileName In files
        ListBox1.Items.Add(fileName.Name)
    Next
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    AxShockwaveFlash1.Movie = Application.StartupPath & "\Games\" & ListBox1.SelectedItem.ToString()
End Sub

Private Sub AddGamesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddGamesToolStripMenuItem.Click
    Dim gd As New OpenFileDialog
    Dim dir As String
    dir = Application.StartupPath & "\Games\"
    gd.Title = "Pick a game to add to the game list"
    gd.Filter = "Shockwave Flash File (*.swf)|*.swf"
    gd.ShowDialog()
    ListBox1.Items.Add(gd.SafeFileName)
    My.Computer.FileSystem.CopyFile(gd.FileName, dir & gd.SafeFileName)
End Sub

Private Sub RefreshGameListToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshGameListToolStripMenuItem.Click
    ListBox1.Items.Clear()
    Dim dir As New IO.DirectoryInfo(Application.StartupPath & "/Games/")
    Dim files As IO.FileInfo() = dir.GetFiles("*.swf")
    Dim fileName As IO.FileInfo
    For Each fileName In files
        ListBox1.Items.Add(fileName.Name)
    Next
End Sub

Private Sub RemoveGamesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveGamesToolStripMenuItem.Click
    Button2.PerformClick()
End Sub

Private Sub CheckForUpdateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckForUpdateToolStripMenuItem.Click
    Updates.Show()
End Sub
End Class

更新表格:

Imports System.IO
Imports System.Net

Public Class Updates
Dim locat As String = System.Reflection.Assembly.GetEntryAssembly.Location
Dim MyDirectory As String = System.IO.Path.GetDirectoryName(locat)
Public totalsize As String
Public link As String
Public Csize As String
Public amount As String

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    My.Computer.FileSystem.RenameFile(MyDirectory + "\" + Me.ProductName + ".exe", Me.ProductName + ".old")
    Timer1.Start()
    BackgroundWorker1.RunWorkerAsync()
    Button1.Enabled = False
End Sub

Private Sub Updates_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Label3.Text = Me.ProductVersion
    Try
        Dim instance As WebClient = New WebClient
        Dim address As String = "https://dl.dropbox.com/u/119965245/XtroPlayer_Version.txt"
        Dim returnValue As String
        returnValue = instance.DownloadString(address)
        Label4.Text = returnValue
        If Not Label4.Text >= Label3.Text Then
        Else
            Button1.Enabled = True
        End If
    Catch ex As Exception

    End Try
    Control.CheckForIllegalCrossThreadCalls = False
End Sub

Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
    Try
        link = "https://dl.dropbox.com/u/119965245/Xtro%20Player.exe"
        Dim size1 As Integer
        Dim wr As WebRequest
        wr = WebRequest.Create(link)
        Dim webr As WebResponse = wr.GetResponse
        size1 = webr.ContentLength
        webr.Close()
        size1 = size1 / 1024
        ProgressBar1.Maximum = size1
        totalsize = size1
        My.Computer.Network.DownloadFile("https://dl.dropbox.com/u/119965245/Xtro%20Player.exe", MyDirectory + "\" + Me.ProductName + ".exe")
    Catch ex As Exception

    End Try
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If File.Exists(MyDirectory + "\" + Me.ProductName + ".exe") Then
        Dim o As New FileInfo(MyDirectory + "\" + Me.ProductName + ".exe")
        amount = o.Length
        amount = amount / 1024
        Csize = amount
        ProgressBar1.Value = amount
    End If
    Label1.Text = Csize + " kbs / " + totalsize + " kbs"
End Sub

Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
    Try
        Shell(MyDirectory + "\" + Me.ProductName + ".exe")
        Me.Close()
    Catch ex As Exception

    End Try
End Sub
End Class

我唯一做的就是改变大会信息的标题,公司,产品,版权和版本信息。

1 个答案:

答案 0 :(得分:0)

尝试检查 / Games / 引用;他们中的一些似乎倒了他们的斜杠。