相关疑难解决方法(0)

Roslyn:工作区在控制台应用程序中加载,但在msbuild任务中没有

我有一个使用此命令的自定义msbuild任务:

var workspace = Workspace.LoadStandAloneProject(csprojPath);
Run Code Online (Sandbox Code Playgroud)

当我运行它时,它会抛出以下错误:

  System.InvalidCastException was unhandled by user code
  Message=Unable to cast transparent proxy to type 'Roslyn.Utilities.SerializableDataStorage'.
  Source=Roslyn.Services
  StackTrace:
       at Roslyn.Utilities.RemoteServices.CreateInstance[T]()
       at Roslyn.Services.Host.TemporaryStorageServiceFactory.CreateService(IWorkspaceServiceProvider workspaceServices)
       at Roslyn.Services.Host.WorkspaceServiceProviderFactory.Provider.c__DisplayClass7.b__4()
       at Roslyn.Utilities.NonReentrantLazy`1.get_Value()
       at Roslyn.Services.Host.WorkspaceServiceProviderFactory.Provider.GetService[TWorkspaceService]()
       at Roslyn.Services.SolutionServices..ctor(IWorkspaceServiceProvider workspaceServices, ILanguageServiceProviderFactory languageServicesFactory)
       at Roslyn.Services.Solution..ctor(SolutionId id, String filePath, VersionStamp version, VersionStamp latestProjectVersion, ILanguageServiceProviderFactory languageServiceProviderFactory, IWorkspaceServiceProvider workspaceServices)
       at Roslyn.Services.Host.SolutionFactoryServiceFactory.SolutionFactoryService.CreateSolution(SolutionId id)
       at Roslyn.Services.Host.TrackingWorkspace.CreateNewSolution(ISolutionFactoryService solutionFactory, SolutionId id)
       at Roslyn.Services.Host.TrackingWorkspace..ctor(IWorkspaceServiceProvider workspaceServiceProvider, Boolean enableBackgroundCompilation, Boolean enableInProgressSolutions)
       at Roslyn.Services.Host.HostWorkspace..ctor(IWorkspaceServiceProvider workspaceServiceProvider, Boolean enableBackgroundCompilation, Boolean enableInProgressSolutions, Boolean enableFileTracking)
       at Roslyn.Services.Host.LoadedWorkspace..ctor(ILanguageServiceProviderFactory languageServiceProviderFactory, IWorkspaceServiceProvider workspaceServiceProvider, …

c# windows roslyn

6
推荐指数
1
解决办法
2288
查看次数

标签 统计

c# ×1

roslyn ×1

windows ×1