I'm currently trying to experiment with the Roslyn Workspaces API on OSX and keep running into the following exception when calling CreateRoslynWorkspace
:
"Could not load type 'System.Reflection.Metadata.ISignatureTypeProvider`1' from assembly 'System.Reflection.Metadata, Version=1.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'."
Is anyone else able to shed some light as to what could be causing this?
Here is the code I am using:
public static class Class1
{
public static IEnumerable<Microsoft.CodeAnalysis.Workspace> Create(string projectPath)
{
var builder = new ProjectContextBuilder().WithProjectDirectory(projectPath);
return builder.BuildAllTargets().Select(context => context.CreateRoslynWorkspace());
}
public static void GetProject()
{
// Entry point
var path = Directory.GetCurrentDirectory() + "/src/DemoLib/project.json";
var result = Create(path).ToList();
}
}
and this is the project.json I am using
{ "version": "1.0.0-*", "buildOptions": { "debugType": "portable" }, "dependencies": { "Microsoft.CodeAnalysis.CSharp": "2.0.0-rc2", "Microsoft.CodeAnalysis.CSharp.Features": "2.0.0-rc2", "Microsoft.CodeAnalysis.CSharp.Workspaces": "2.0.0-rc2", "Microsoft.DotNet.ProjectModel": "1.0.0-rc3-1-003177", "Microsoft.DotNet.ProjectModel.Loader": "1.0.0-preview2-1-003177", "Microsoft.DotNet.ProjectModel.Workspaces": "1.0.0-preview2-1-003177" }, "frameworks": { "netcoreapp1.1": { "imports": [ "portable-net45+win8" ] } } }
Here is the entire stack trace too:
" at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)\n at System.Reflection.RuntimeAssembly.get_DefinedTypes()\n at System.Composition.Hosting.ContainerConfiguration.b__0(Assembly a)\n at System.Linq.Enumerable.d__159
2.MoveNext()\n at System.Composition.TypedParts.TypedPartExportDescriptorProvider..ctor(IEnumerable
1 types, AttributedModelProvider attributeContext)\n at System.Composition.Hosting.ContainerConfiguration.CreateContainer()\n at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create(IEnumerable1 assemblies)\n at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.get_DefaultHost()\n at Microsoft.DotNet.ProjectModel.Workspaces.ProjectJsonWorkspace..ctor(ProjectContext context)\n at Microsoft.DotNet.ProjectModel.Workspaces.WorkspaceProjectContextExtensions.CreateRoslynWorkspace(ProjectContext context)\n at ClassLibrary.Class1.<>c.<Create>b__0_0(ProjectContext context) in /Users/personal/Dev/RoslynWorkspace2/src/Lib/Library.cs:line 16\n at System.Linq.Enumerable.SelectEnumerableIterator
2.MoveNext()\n at System.Collections.Generic.List1..ctor(IEnumerable
1 collection)\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\n at ClassLibrary.Class1.GetProject() in /Users/personal/Dev/RoslynWorkspace2/src/Lib/Library.cs:line 21\n at WebAPIApplication.Controllers.ValuesController.Get() in /Users/personal/Dev/RoslynWorkspace2/src/WebAPIApplication/Controllers/ValuesController.cs:line 13\n at lambda_method(Closure , Object , Object[] )\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__28.MoveNext()"
Add "System.Reflection.Metadata" as dependency to the project.json.