How do I insert references to use the ScriptEngine class?

4

Based on the question Compile string as code includes in my project the ScriptEngine class, however, it is not being found in the references:

using Microsoft.CodeAnalysis.Scripting;
using Microsoft.CodeAnalysis.Scripting.CSharp; //Nesta

Installing with NuGet Packages for Solution I searched for Microsoft.CodeAnalysis.Scripting and installed it, but did not install the next ( Microsoft.CodeAnalysis.Scripting.CSharp ) for incompatibility.

I can install the reference Microsoft.CodeAnalysis.Scripting.CSharp by the console with the commands (in order in the console):

  

PM > Install-Package Microsoft.DiaSymReader.Native
  PM > Install-Package Microsoft.CodeAnalysis.Scripting.CSharp -Pre

But in this way ScriptEngine is not being found.

What do I do to use ScriptEngine ?

    
asked by anonymous 30.03.2017 / 20:43

1 answer

0

Apparently there has been a change in how new versions of the .NET Compiler Platform work with creating script engines to execute arbitrary code. See for example this post in StackOverflow .

As suggested in the answer, you can try to use the class CSharpScript.Create() instead of new ScriptEngine() .

If it is not the definitive solution for your code then it might be a search path.

    
30.10.2017 / 16:51