My project is a complex data modelling tool. To save me having to write bespoke reports for it, I added the facility for users to write macros to extract the data they need (in reality it is just me who writes these macros, but it saves me having to recompile and re-release the tool). This used to work absolutely fine, but it has suddenly stopped working and I have no idea why. The following code, which strips the issue to its bare-bones, works in a fresh project, but the exact same code fails in my actual project. They are both targeting the same .Net Framework (4.7.2) and they both have the same version of Microsoft.CodeAnalysis.CSharp.Scripting installed (4.9.2) via Nuget.
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
namespace ConsoleApp
{
internal class Program
{
static void Main(string[] args)
{
var options = ScriptOptions.Default;
var globals = new Globals() { };
var macro = "";
var scriptState = CSharpScript.RunAsync(macro, options, globals);
}
}
public class Globals { }
}
The StackOverflowException occurs on the ‘var scriptState = ‘ line and it happens instantly.
I have tried cleaning and rebuilding and reinstalling the nuget packages. As I said, the code above works in a new project, but just not in my existing project.