Compiling .cs from .Net applications

Is there a managed API for compiling C # applications (into memory or disk)? I assume it exists because SharePoint compiles ASP.NET pages in memory. We want to use it at runtime, generate Linq DataContextand compile them for different projects.

+3
source share
2 answers

Take a look at the Microsoft.CSharp.CSharpCodeProvider class . There is sample code on this page on how to use this class to compile C # sources.

Note . This class cannot be used in partial trust. You need to run with full trust in order to be able to run the C # compiler.

+3
source

, CSharpCodeProvider - , .

# "Snippy", "" # - , , CSharpCodeProvider. - .

+1

Source: https://habr.com/ru/post/1698594/


All Articles