Results 1 to 10 of 10

Thread: How to creat exe file from my application on runtime

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    9

    How to creat exe file from my application on runtime

    Hello everybody. I have a problem about how to creat exe file from my application on runtime. That is:
    I have a program A, I want A can dynamic creat a program B on runtime. B have been custom by some parameter that user input to A.
    How can I do this? Who can teach me? Thanks!!!

  2. #2

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    9
    anybody can help me?

  3. #3
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    you don't mean simply copy an exe from locatin x to the end user's hard-drive, do you? or do you mean actually spit out a newly compiled app? the latter wouldn't be possible since the programs you create in vb are not compilers. They're just desktop applications.

  4. #4
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    this?
    VB Code:
    1. option strict on
    2. imports system
    3. imports system.io
    4. imports system.diagnostics
    5. imports system.windows.forms
    6. public class example
    7.    inherits form
    8.    
    9.    withevents b1 as new button()
    10.    withevents b2 as new button()
    11.    dim f as string="example"
    12.    sub new()
    13.       ' button
    14.       b1.text="compile"
    15.       b1.setbounds(10,10,75,23)
    16.       b2.text="run"
    17.       b2.setbounds(10,38,75,23)
    18.      
    19.       addhandler b1.click, addressof b1_click
    20.       addhandler b2.click, addressof b2_click
    21.       me.controls.addrange(new control(){b1,b2})  
    22.    end sub
    23.    
    24.    sub b1_click(sender as object,e as eventargs)
    25.       process.start("vbc",f & ".vb /r:system.dll,system.windows.forms.dll")
    26.       console.writeline("compiling...")
    27.    end sub
    28.    
    29.    sub b2_click(sender as object,e as eventargs)
    30.       process.start(f)
    31.       console.writeline("running..")
    32.    end sub
    33.  
    34.    shared sub main()
    35.       application.run(new example())
    36.    end sub
    37. end class

  5. #5
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Originally posted by Andy
    you don't mean simply copy an exe from locatin x to the end user's hard-drive, do you? or do you mean actually spit out a newly compiled app? the latter wouldn't be possible since the programs you create in vb are not compilers. They're just desktop applications.
    Actually, .NET comes with classes that access the compiler that let you compile to IL.

    Ive never worked with it before though, but I know its doable. And probably not that difficult.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  6. #6
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    really? i would have never known that. thats interesting. what are some situations where you might need to compile as an end user?

  7. #7
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Maybe you want to write your own IDE and add compiling features to it. Or you want to add scritping type features to your app, but instead of creating your own language and uncompiled at that, you could let the user write full blown VB.NET or C# and your app can compile it at run time.

    Just use your imagination.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  8. #8
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    for lack of better words: nifty! lol

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    9
    Thank you everybody!!! I get it.

  10. #10
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    We have a guy at work that is creating a class, compiling it to a dll, then loading that dll in its own app domain running it using reflection, then unloading the dll after he is done.

    This is so very much possible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width