何らかの理由で、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
私がそれに対して行った他の唯一のことは、アセンブリ情報のタイトル、会社、製品、著作権、およびバージョン情報を変更することでした.