Search code examples
c#exceptionscriptingroslynroslyn-code-analysis

Roslyn / MicrosoftCodeAnalysis.CSharp.Scripting throws 'FileNotFoundException'


I referenced via Nuget Microsoft.CodeAnalysis.CSharp.Scripting Version 2.3.0.0 which pulled in numerous references, including System.IO.FileSystem Version 4.0.2.0.

When I try to execute the following code return await _scriptObjects[scriptName].Script.RunAsync(_scriptObjects[scriptName].SharedObject, cancellationToken);

An error is thrown. What am I missing?

enter image description here


Solution

  • I think I found the solution...adding

    <PropertyGroup> 
         <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedir‌​ects> 
         <GenerateBindingRedirectsOutputType>true</GenerateBindingRed‌​irectsOutputType> 
    </PropertyGroup>
    

    to the project file generated the binding redirects automatically and solved my problem. I also added those to other project files that have depend on my original Roslyn script class library.