本文介绍了使用ICodeCompiler将文本文件编译为exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 您好,我想知道如何才能完成这项工作......我有一个包含两个类的文本文件,但编译器一直处于失败状态...现在有点沮丧......一直在努力争取一个星期......请帮忙。 在文本文件中...如果您想查看我可以通过电子邮件发送的代码 1.公共舱位表格1 2.公共舱位设置 这是我走了多远 私函数编译(ByVal输出为字符串)As Boolean Dim result As Boolean Dim vbcode As VBCodeProvider = New VBCodeProvider Dim compiler As ICodeCompiler = vbcode.CreateCompiler() Dim compargs As New CompilerParameters() compargs.GenerateInMemory = False Dim references()As String = {" System.Windows.Forms.dll"," System.Drawing.dll"," Microsoft.VisualBasic.dll"," System.dll" ;} compa rgs.CompilerOptions =" / target:winexe / m:Form1 / win32icon:" &安培; " C:\ install.ico" compargs.GenerateExecutable = True compargs.IncludeDebugInformation = False compargs.OutputAssembly = output compargs.TreatWarningsAsErrors = False compargs.ReferencedAssemblies.AddRange(参考) Dim res As CompilerResults res = compiler.CompileAssemblyFromFile(compargs," C:\ TDIR \prg.txt") 如果res.Errors.Count> 0然后 结果=错误 否则 结果=真 结束如果 返回结果 结束函数解决方案 喘息后我决定冷静下来......看了一下板球然后开始思考 我改变了整个文本文件,检查下面的代码......看哪......工作原理!我太棒了! 进口设置 进口系统 进口System.IO Imports System.Text Imports System.Drawing 进口System.Windows.Forms 进口System.ComponentModel Imports System.CodeDom.Compiler Imports System.Collections.Generic Imports System.Runtime.Serialization.Formatters.Binary 公共类Form1 继承表格 Dim WithEvents myButton As Button Public Sub New() myButton = New Button() dim [set] as New Settings( ) myButton.Text = [set] .MText myButton.Top = 70 myButton.Left = 70 Me.controls.add(myButton) 结束次级 Private Sub myButtonClick(ByVal sender As Object,ByVal e As EventArgs)_ 处理myButton.Click MessageBox.Show(Hello World!) End Sub 结束班级 < serializable> _ 公共类设置 Public Sub New() End Sub Public m_text as String =BOOOOO Public Property MText()As String Get 返回m_text 结束获取 设置(值为字符串) m_text = value 结束套票 结束物业 结束班 Hi there, I would like to find out how I can make this work... I have a Text file containing two classes, but the compiler keeps on failing... A bit frustrated now... Been battling for about a week... Please help.IN TEXT FILE... If you would like to see the code I can send it via email1. Public Class Form12. Public Class SettingsThis is how far I gotPrivate Function Compile(ByVal output As String) As Boolean Dim result As Boolean Dim vbcode As VBCodeProvider = New VBCodeProvider Dim compiler As ICodeCompiler = vbcode.CreateCompiler() Dim compargs As New CompilerParameters() compargs.GenerateInMemory = False Dim references() As String = {"System.Windows.Forms.dll", "System.Drawing.dll", "Microsoft.VisualBasic.dll", "System.dll"} compargs.CompilerOptions = "/target:winexe /m:Form1 /win32icon:" & "C:\install.ico" compargs.GenerateExecutable = True compargs.IncludeDebugInformation = False compargs.OutputAssembly = output compargs.TreatWarningsAsErrors = False compargs.ReferencedAssemblies.AddRange(references) Dim res As CompilerResults res = compiler.CompileAssemblyFromFile(compargs, "C:\TDIR\prg.txt") If res.Errors.Count > 0 Then result = False Else result = True End If Return resultEnd Function 解决方案 这篇关于使用ICodeCompiler将文本文件编译为exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-06 12:02