Woofer Posted February 5, 2003 Posted February 5, 2003 Please help!!! I want to programmatically compile a project that has a number of different forms that link together i.e. clicking on a button on one form closes that form and opens another form. I have tried using the ICodeCompiler but errors have occured which I think are becuase the forms to be displayed have import statements. Also, the only examples of programmatically compiling code I have seen have only had one source file, and I have several, so how do I deal with this? Thanks Quote
*Gurus* divil Posted February 5, 2003 *Gurus* Posted February 5, 2003 Please post all the relevant code you have so far, and exactly what requirements you have with regards to referencing assemblies and imports statements in the compiled assembly. Also what language you are targetting. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Woofer Posted February 6, 2003 Author Posted February 6, 2003 I am using VB.Net. and I need to import System.io I attach the project that I wish to programmatically compile. The reason that I wish to programmatically compile the project is that my program will be changing some of the code in the 'pages' then compiling and running that program (increment 2d). Thanks for you helpcode.txt Quote
*Gurus* divil Posted February 6, 2003 *Gurus* Posted February 6, 2003 Here's a code example for something that compiles a file on disk, adding references, to a Windows exe file. Dim c As CodeDom.Compiler.ICodeCompiler Dim p As New CodeDom.Compiler.CompilerParameters() Dim r As CodeDom.Compiler.CompilerResults Dim err As CodeDom.Compiler.CompilerError c = New Microsoft.VisualBasic.VBCodeProvider().CreateCompiler() 'Set up compiler parameters here p.ReferencedAssemblies.Add("System.dll") p.ReferencedAssemblies.Add("System.Drawing.dll") p.ReferencedAssemblies.Add("System.Windows.Forms.dll") p.GenerateExecutable = True p.OutputAssembly = "c:\out.exe" p.CompilerOptions &= "/t:winexe" p.MainClass = "form1" 'Compile r = c.CompileAssemblyFromFile(p, "c:\file.vb") 'Analyse results If r.Errors.Count <> 0 Then 'Show errors For Each err In r.Errors Next End If 'Do something with compiled assembly (r.PathToAssembly) Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Threads Posted February 7, 2003 Posted February 7, 2003 That is a good sample, divil. Thanks Quote mov ax, 13h int 10h
Woofer Posted February 10, 2003 Author Posted February 10, 2003 Thanks, that example really helped. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.