Westwind CSharp Scripting
Dynamically compile and execute CSharp code at runtime
for .NET 4.52 and later
Get it from Nuget:
Install-Package Westwind.Scripting
The small CSharpScripting
class provides an easy way to compile and execute C# on the fly from source code at runtime using the .NET compiler services on full Framework .NET. You can use Roslyn compilation for the latest C# features, or classic C# 5 features.
This class makes is very easy to integrate simple scripting or text merging features into applications with minimal effort.
This library provides:
Execution Features
ExecuteCode()
- Execute an arbitrary block of codeEvaluate()
- Evaluate an expression from a code stringExecuteMethod()
- Execute one or more methods from sourceCompileClass()
- Generate a class instance from C# code
Supported features
- Assembly Caching so not every execution generates a new assembly
- Ability to compile entire classes and execute them
- Automatic Assembly Cleanup at shutdown
- Use Roslyn or Classic C# compiler interchangeably
- Display errors and source and line numbers
© West Wind Technologies, 1996-2019 • Updated: 02/25/19
Comment or report problem with topic