Hallo,
hier ein Code mit dem man VB-Code zu einer Exe kompilieren kann. Voraussetzung ist das Framework 3.5.
Ansonsten lässt sich auch gut der System.CodeDom.Compiler.CodeCompiler oder der Microsoft.VisualBasic.VBCodeProvider nutzen.
Hier einige Beispielcodes zum testen:
Mit C# sieht's ähnlich aus.
Viel Spaß damit
hier ein Code mit dem man VB-Code zu einer Exe kompilieren kann. Voraussetzung ist das Framework 3.5.
VB.NET-Quellcode
- Private Function CompileCode(ByVal code As String, ByVal tmpfile As String, ByVal outpath As String) As Boolean
- IO.File.WriteAllText(tmpfile, code)
- If IO.File.Exists(outpath) Then IO.File.Delete(outpath)
- Dim p As New Process With {.StartInfo = New ProcessStartInfo With {.Arguments = " /t:exe """ & tmpfile & """", .WindowStyle = ProcessWindowStyle.Hidden, .FileName = IO.Path.Combine(New IO.FileInfo(Application.ExecutablePath).Directory.Root.FullName, "WINDOWS\Microsoft.NET\Framework\v3.5\vbc.exe")}}
- p.Start()
- p.WaitForExit()
- Return IO.File.Exists(outpath)
- End Function
Ansonsten lässt sich auch gut der System.CodeDom.Compiler.CodeCompiler oder der Microsoft.VisualBasic.VBCodeProvider nutzen.
Hier einige Beispielcodes zum testen:
VB.NET-Quellcode
- Module Module1
- Sub Main()
- System.Console.WriteLine("Mit dem Vb Codecompiler kompilierter Source!")
- Console.Writeline("Zahl eingeben: ")
- Do Until IsNumeric(Console.Readline)
- Console.Writeline("Zahl eingeben: ")
- Loop
- Console.Writeline("Zahl gültig.")
- System.Console.ReadLine()
- SchreibHallo()
- End Sub
- Sub SchreibHallo()
- Console.Writeline("Hallo!")
- Console.Read()
- End Sub
- End Module
Mit C# sieht's ähnlich aus.
Viel Spaß damit
Dieser Beitrag wurde bereits 5 mal editiert, zuletzt von „kevin89“ ()