| Динамическое выполнение кода |
|
Imports Microsoft.VisualBasic Imports System.CodeDom.Compiler Код: Dim VB As New VBCodeProvider(), _ Compiler As ICodeCompiler = VB.CreateCompiler(), _ Param As New CompilerParameters() Dim Asm As System.Reflection.Assembly, sCode As String sCode = "ЗДЕСЬ КОД, ОБЯЗАТЕЛЬНО IMPORTS НУЖНЫЕ ССЫЛКИ!" Param.GenerateExecutable = True Param.IncludeDebugInformation = False Param.OutputAssembly = "Test.exe" For Each Asm In AppDomain.CurrentDomain.GetAssemblies() Param.ReferencedAssemblies.Add(Asm.Location) Next Dim Results As CompilerResults = Compiler.CompileAssemblyFromSource(Param, sCode) If Results.Errors.Count > 0 Then Dim Err As CompilerError Dim ErrorString As String For Each Err In Results.Errors ErrorString &= Err.ToString() Next MsgBox(ErrorString) Else Dim ProcessInfo As New ProcessStartInfo("Test.exe") Process.Start(ProcessInfo) End If |