CodeDom Vb.net 2010帮助编译一个可执行文件 [英] Help with CodeDom Vb.net 2010 compileng an executable

查看:65
本文介绍了CodeDom Vb.net 2010帮助编译一个可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.
我有个问题.我正在尝试使用codedom将一些代码即时编译为可执行文件.我能找到的唯一教程是编译代码并在内存中运行它,而没有实际创建可在以后运行的可执行文件.我已经在Google上度过了几个小时,到目前为止没有发现任何有用的信息.

我正在使用Visual Basic 2010(如果有任何区别,请在VS专业版中使用).到目前为止,我已经能够设置所有编译器参数(但我想),但无法弄清楚如何真正地将其编译.到目前为止,这里是我得到的代码

Hi guys.
I have a problem. I am trying to use codedom to compile some code on the fly to an executable. The only tutorials I can find are for compileing the code and running it within memory without actually creating an executable that can be run later. I''ve spent hours on google and not found anything helpful so far.

I am useing visual basic 2010 (in VS professional if that makes any diffrence). So far I have been able to set all the compiler paramiters (I think) But cant work out how to actually get it to compile. Heres the code I have got so far

Public Sub compile(byval dlls as string(), byval source_files as string())
    Dim provider As VBCodeProvider = New VBCodeProvider
    Dim cp As CompilerParameters = New CompilerParameters
    cp.GenerateInMemory = False
    cp.GenerateExecutable = True
    cp.OutputAssembly = output 'Output is a public sting that is declared elsewhere
    cp.TreatWarningsAsErrors = False
    cp.ReferencedAssemblies.AddRange(dlls)
    cp.WarningLevel = 3


End Sub



我希望我没有错过任何真正明显的东西.在此先感谢

Dan



I hope i havent missed something really obvious here. Thanks in advance

Dan

推荐答案

差不多.缺少了什么?如果未在内存中生成,则需要指定程序集的输出可执行文件cp.OutputAssembly = exeName.谁来为您编译它并得到错误?使用cp.CompileAssemblyFromSource,返回CompilerResults,将其显示在用户界面中.

简而言之,您怎么不看Microsoft代码示例?此处:
http://msdn.microsoft.com/en-us/library/microsoft. visualbasic.vbcodeprovider.aspx#Y1646 [ ^ ].

—SA
That''s pretty much it. What''s missing? If you do not generate in memory, you need to specify output executable file for assembly, cp.OutputAssembly = exeName. Who will compile it for you and get errors? Use cp.CompileAssemblyFromSource, return CompilerResults, present them in you UI.

In few words, how come you did not look at Microsoft code sample? Here:
http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.vbcodeprovider.aspx#Y1646[^].

—SA


谢谢SA,我确实看过MSDN,但一定只是忽略了一些东西.当我开始进行编译时,我已经在该项目上工作了5个小时.
我会看一下,如果还有其他问题,请发帖
Thankyou SA, I did look on MSDN but must have just overlooked something. I had been working on the project for 5 hours when I started working on the compile.
I will take a look, and post if i have any more problems


这篇关于CodeDom Vb.net 2010帮助编译一个可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆