C # code Dynamic compilation, dynamic execution, dynamic debugging

Source: Internet
Author: User
Tags bool

A few days ago I saw a story about. NET Dynamic compilation. NET, is very inspired by the dynamic compilation. On this basis I do some encapsulation, in order to make the call simpler, and increase the dynamic code debugging support, the same code only compile once support, code changes automatically recompile, code reference file automatic loading and manual loading functions.

As pictured above, the class Csharpprovider I encapsulate is simple, and here's how some of the public members are used.

Public properties

assemblyFileName: This property specifies the name of the accessory that is generated dynamically after compilation.

CompilerParameters: This property specifies the parameters of the compilation

References: This property specifies the reference in the compiled code. The caller can add its own reference as long as it calls References.add ("Xxx.dll"), and the class is automatically loaded for all references to the System namespace, without the need to join manually. For the user's own component, if the reference file is not manually specified, the class is automatically guessed based on the namespace name.

Sourcecodefileencoding: If compiled as a file, specifies the encoding type of the file.

Public methods

public bool Compile (string code)

Enter a code string and compile

public bool Compilefromfile (string sourcecodefilename)

Compiling the input code file

public Object CreateInstance (string code, String typefullname)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.