2

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

Matt
  • 7,004
  • 11
  • 71
  • 117
  • Do you have any binding redirects set in your App.config? Maybe one that tries to redirect any version for System.IO.FileSystem to v4.0.1.0 ? – Bogey Jul 19 '17 at 12:56
  • There are many binding redirects. The relevant I see (I have not added them myself they were generated when I pulled in the Scripting libraries via Nuget): ` ` – Matt Jul 19 '17 at 12:58
  • Right - hmm my project doesn't have a redirect for that assembly. I'm not using Scripting libraries, but many other Roslyn ones. Does it help if you either remove this entry altogether, or (unlikely if your assembly reference is for v4.0.2.0 indeed) set newVersion="4.0.1.0" instead? – Bogey Jul 19 '17 at 13:01
  • Will try that and revert back, thanks @Bogey – Matt Jul 19 '17 at 13:04
  • @Bogey, neither removing all redirects nor adjusting the specific redirect to version 4.0.1.0 worked. – Matt Jul 19 '17 at 13:43
  • Hmm. Can only think of 3 more things then: 1) Check that every CodeAnalysis-related package is actually on v2.3 (they had some issues on Nuget until earlier this week where some were still only on v2.2 while others were on v2.3, causing some issues - don't think any of the ones you're using though), 2) Double check the System.IO.FileSystem v4.0.2.0 assembly is indeed copied to your output directory, and 3) you are using this in a relatively standard way (e.g. just compile a normal executable)? Eg I had some issues using Roslyn in an Excel Addin as binding redirects were ignored in that setup – Bogey Jul 19 '17 at 13:54
  • @Bogey, will try that, I use it just to compile and run a script within a string. – Matt Jul 19 '17 at 13:59
  • @Bogey, thanks for your suggestion, unfortunately none work. Same runtime error. – Matt Jul 19 '17 at 14:22
  • Bummer, I'm out of ideas then. If nobody smarter replies later on ;) - would try producing a workable minimal example in a new solution. If still same issue, possibly report on Roslyn's Github issues page – Bogey Jul 19 '17 at 14:26
  • already created a new project in order to isolate the issue to no avail. Thanks for your help! – Matt Jul 19 '17 at 14:27

2 Answers2

0

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.

Matt
  • 7,004
  • 11
  • 71
  • 117
-1

This issue is because roslyn folder not created in bin because of template issues. edit the project file will solve this.

Could not find a part of the path ... bin\roslyn\csc.exe

Immanuel
  • 167
  • 1
  • 8