Compile code at runtime?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adam Clauss

    #1

    Compile code at runtime?

    OK, I just ran across a program that did this and I am wondering is this
    something they coded in themselves, or is there already helper classes, etc
    available to assist in this.

    The application compiles many C# files at runtime and then uses them.
    How easy/hard is it to do such a thing?

    Thanks
    --
    Adam Clauss
    cabadam@tamu.ed u


  • Alan Pretre

    #2
    Re: Compile code at runtime?

    "Adam Clauss" <cabadam@tamu.e du> wrote in message
    news:OAvgtaojDH A.2060@tk2msftn gp13.phx.gbl...[color=blue]
    > The application compiles many C# files at runtime and then uses them.
    > How easy/hard is it to do such a thing?[/color]

    Hi. Use System.CodeDom. Compiler.ICodeC ompiler to instantiate the compiler
    you want, eg C# or VB.NET, add references using
    System.CodeDom. Compiler.Compil erParameters.Pa rameters.Refere ncedAssemblies. A
    dd(), then compile it using
    System.CodeDom. Compiler.Compil eAssemblyFromSo urce().

    There's a few details to take care of that I've omitted but it's not too
    bad.

    -- Alan


    Comment

    Working...