Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using an AdHocWorkspace results in "The language 'C#' is not supported."

Using the RC2 of Microsoft.CodeAnalysis.CSharp.Workspaces in VS2015, this code throws an exception:

var tree = CSharpSyntaxTree.ParseText(...);
var workspace = new AdhocWorkspace();
var newRoot = Simplifier.Expand(tree.GetRoot(),
    compilation.GetSemanticModel(tree, false),
    workspace,
    n => true,
    true,
    CancellationToken.None);

The exception message is "The language 'C#' is not supported."

What am I missing to make this work?

like image 520
Aethon Invictus Avatar asked Jun 02 '15 16:06

Aethon Invictus


Video Answer


1 Answers

You need to add a reference to the C# Workspaces NuGet package.

This will copy the C# DLLs to your output, and let Roslyn's MEF scanner see the language services.

like image 179
SLaks Avatar answered Oct 14 '22 01:10

SLaks