创建新的Microsoft.CodeAnalysis.CustomWorkspace - 得到了ReflectionTypeLoadException

时间:2014-08-28 09:55:08

标签: c# roslyn

我尝试在.NET编译器平台(" Roslyn")样本中创建类似ConsoleClassifier的东西。 (Microsoft.CodeAnalysis v0.7 ...)此时我得到ReflectionTypeLoadException

CustomWorkspace workspace = new CustomWorkspace();

ReflectionTypeLoadException
{"Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."}
LoaderExceptions: FileNotFoundException
{"Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. A rendszer nem találja a megadott fájlt.":"Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"}

我错过了什么?

堆栈跟踪:

at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetExports(ImportDefinition definition)
   at System.ComponentModel.Composition.Hosting.AggregateCatalog.GetExports(ImportDefinition definition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InternalGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InnerCatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportsCore(Type type, Type metadataViewType, String contractName, ImportCardinality cardinality)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportsCore[T,TMetadataView](String contractName)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports[T,TMetadataView](String contractName)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports[T,TMetadataView]()
   at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.<GetExports>b__6[TExtension,TMetadata](ExportKey _)
   at System.Collections.Immutable.ImmutableInterlocked.GetOrAdd[TKey,TValue](ImmutableDictionary`2& location, TKey key, Func`2 valueFactory)
   at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.GetExports[TExtension,TMetadata]()
   at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.MefWorkspaceServices..ctor(MefHostServices host, Workspace workspace)
   at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.CreateWorkspaceServices(Workspace workspace)
   at Microsoft.CodeAnalysis.Workspace..ctor(HostServices host, String workspaceKind)
   at Microsoft.CodeAnalysis.CustomWorkspace..ctor(HostServices host, String workspaceKind)
   at Microsoft.CodeAnalysis.CustomWorkspace..ctor()

1 个答案:

答案 0 :(得分:5)

你需要安装VS&#34; 14&#34;构建工具包。您可以在ISO here中找到它。