Click here to Skip to main content
15,913,280 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: VB HELP, Need someone that knows how to write code for a simple task Pin
Tall Dude1-Apr-07 20:30
Tall Dude1-Apr-07 20:30 
Questionmultiple checkbox within multiple groupbox(vb.net) Pin
abbss.gaurav1-Apr-07 7:35
abbss.gaurav1-Apr-07 7:35 
QuestionDifference between IE View Source and OpenURL data Pin
Huling Parker1-Apr-07 7:33
Huling Parker1-Apr-07 7:33 
Questionmultiple checkbox within multiple groupbox(vb.net) Pin
abbss.gaurav1-Apr-07 6:56
abbss.gaurav1-Apr-07 6:56 
AnswerRe: multiple checkbox within multiple groupbox(vb.net) Pin
Dave Kreskowiak1-Apr-07 7:12
mveDave Kreskowiak1-Apr-07 7:12 
QuestionAdding fields in a table adapter not showing in code. Pin
steve_rm1-Apr-07 5:33
steve_rm1-Apr-07 5:33 
AnswerRe: Adding fields in a table adapter not showing in code. Pin
Johan Hakkesteegt4-Apr-07 2:30
Johan Hakkesteegt4-Apr-07 2:30 
QuestionSaving a compiled assembly Pin
Nick Rioux1-Apr-07 5:12
Nick Rioux1-Apr-07 5:12 
I've been trying to get an application that can compile code at runtime, then save it as a .exe file.
So basically what I did was go on MSDN, 'steal' some code (yeah, I know I shouldn't...) that compiled VB and try to change it so it could also save it.
Public Class Form1<br />
<br />
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
        CodeEmitter.RunCode("Microsoft.VisualBasic.MsgBox(" & """" & "Hello World" & """" & ")")<br />
<br />
    End Sub<br />
End Class<br />
Class CodeEmitter<br />
<br />
    Shared Sub RunCode(ByVal code As String)<br />
<br />
        Dim cmplrParms As New CodeDom.Compiler.CompilerParameters<br />
<br />
        cmplrParms.GenerateExecutable = True<br />
<br />
        cmplrParms.OutputAssembly = "C:/VBCompile.exe"<br />
<br />
        cmplrParms.TreatWarningsAsErrors = False<br />
<br />
        cmplrParms.WarningLevel = 4<br />
<br />
        cmplrParms.ReferencedAssemblies.AddRange(New String() {"System.dll", "Microsoft.VisualBasic.dll"})<br />
<br />
        code = String.Format("Public NotInheritable Class EmittedClass{0}Public Shared Sub DoWork{0}{1}{0}End Sub{0}End Class", Environment.NewLine, code)<br />
        Dim pvdr As New VBCodeProvider<br />
<br />
        Dim rslts As CodeDom.Compiler.CompilerResults = pvdr.CompileAssemblyFromSource(cmplrParms, code)<br />
<br />
        MsgBox("Path: " & rslts.PathToAssembly)<br />
<br />
        Dim assmbly As Reflection.Assembly = rslts.CompiledAssembly<br />
<br />
        Dim t As Type = assmbly.GetType("EmittedClass")<br />
<br />
        t.InvokeMember("DoWork", Reflection.BindingFlags.InvokeMethod Or Reflection.BindingFlags.Public Or Reflection.BindingFlags.Static, _<br />
        Nothing, Nothing, Nothing)<br />
<br />
    End Sub<br />
<br />
End Class


The original code worked until I changed
cmplrParms.GenerateInMemory = True
to
cmplrParms.GenerateExecutable = True<br />
<br />
cmplrParms.OutputAssembly = "C:/VBCompile.exe"


Now I get an error FileNotFoundException at
Dim assmbly As Reflection.Assembly = rslts.CompiledAssembly
because it turns out that nothing was ever compiled to C:\ in the first place! Confused | :confused:


Thanks in advance for any help!
AnswerRe: Saving a compiled assembly Pin
Ri Qen-Sin1-Apr-07 17:39
Ri Qen-Sin1-Apr-07 17:39 
NewsRe: Saving a compiled assembly [modified] *Solved* Pin
Nick Rioux2-Apr-07 1:05
Nick Rioux2-Apr-07 1:05 
QuestionButton text problem in vb.net 2003 Window Application. Pin
amaneet1-Apr-07 4:14
amaneet1-Apr-07 4:14 
AnswerRe: Button text problem in vb.net 2003 Window Application. Pin
Nick Rioux1-Apr-07 5:26
Nick Rioux1-Apr-07 5:26 
Questionhelp me Pin
phowarso1-Apr-07 2:39
phowarso1-Apr-07 2:39 
AnswerRe: help me Pin
Nick Rioux1-Apr-07 5:30
Nick Rioux1-Apr-07 5:30 
AnswerRe: help me Pin
Dave Kreskowiak1-Apr-07 7:09
mveDave Kreskowiak1-Apr-07 7:09 
AnswerRe: help me Pin
lmoelleb1-Apr-07 23:29
lmoelleb1-Apr-07 23:29 
QuestionHow can I write on image and save it again? Pin
Omar Mallat31-Mar-07 23:45
professionalOmar Mallat31-Mar-07 23:45 
AnswerRe: How can I write on image and save it again? Pin
Guffa1-Apr-07 4:50
Guffa1-Apr-07 4:50 
GeneralRe: How can I write on image and save it again? Pin
Omar Mallat1-Apr-07 18:28
professionalOmar Mallat1-Apr-07 18:28 
AnswerRe: How can I write on image and save it again? Pin
Guffa1-Apr-07 21:03
Guffa1-Apr-07 21:03 
GeneralRe: How can I write on image and save it again? Pin
Omar Mallat2-Apr-07 18:27
professionalOmar Mallat2-Apr-07 18:27 
AnswerRe: How can I write on image and save it again? Pin
Guffa2-Apr-07 21:05
Guffa2-Apr-07 21:05 
GeneralRe: How can I write on image and save it again? Pin
Omar Mallat2-Apr-07 23:17
professionalOmar Mallat2-Apr-07 23:17 
AnswerRe: How can I write on image and save it again? Pin
Guffa3-Apr-07 0:39
Guffa3-Apr-07 0:39 
AnswerRe: How can I write on image and save it again? Pin
Dave Kreskowiak1-Apr-07 7:06
mveDave Kreskowiak1-Apr-07 7:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.