2013-03-13 36 views
1

由于某种原因,我现在尝试在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 

我没有到这是改变大会信息的标题,公司,产品,版权和版本信息唯一的其他东西。

+0

当你说它“不运行”,会发生什么?你有错误吗?如果是这样,与该错误相关的消息是什么?我现在没有VB.NET编译器,所以我不能尝试你的示例代码。 – 2013-03-13 23:31:27

+0

它在Visual Basic中完成,但基本上它不打开,即使在兼容模式下运行时也不会出现错误。 – 2013-03-13 23:44:57

+0

检查所有参考文献是否具有“本地副本”。 – Jaxedin 2013-03-14 01:29:36

回答

0

试着检查你/游戏/参考;其中一些似乎有倒置的斜线。

+0

如果你在谈论文件路径,这不太可能是问题。当涉及到斜线时,Windows API非常多元文化:它们在反斜杠和斜杠上都能正常工作。 – 2013-03-14 03:23:04

+0

很好,谢谢科迪。 – 2013-03-14 10:04:48

相关问题