如何使Unity打开Visual Studio 2017来编辑代码

时间:2019-04-08 12:30:32

标签: visual-studio unity3d

基本上,每次我尝试统一打开c#文件时,都会得到:

消息“解决方案中的一个或多个项目未正确加载。请查看输出窗口以获取详细信息”

后跟“遇到了异常。可能是由扩展引起的。您可以通过检查文件来获取更多信息...”该文件确实很长,因此我仅粘贴错误:

  

568错误软件包[CSharpPackage]的LegacySitePackage失败源:'Microsoft.VisualStudio.LanguageServices'说明:无法加载文件或程序集'Microsoft.CodeAnalysis,版本= 2.10.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35'或一个它的依赖关系。该系统找不到指定的文件。 System.IO.FileNotFoundException:无法加载文件或程序集“ Microsoft.CodeAnalysis,版本= 2.10.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35”或其依赖项之一。该系统找不到指定的文件。文件名:Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractPackage`2.Initialize()处的Microsoft.CodeAnalysis,Version = 2.10.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35' Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp)上的.CSharpPackage.Initialize()WRN:程序集绑定日志记录已关闭。要启用程序集绑定失败日志记录,请将注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog](DWORD)设置为1。注意:程序集绑定失败日志记录会降低性能。要关闭此功能,请删除注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog]。 {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:50.397

     

569错误SetSite软件包CSharpPackage {13C3BBB4-F18F-4111-9F54-A0FB010D9194}失败80070002 VisualStudio 2019/04/08 11:04:50.403

     

570错误结束程序包加载[CSharpPackage] {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:50.408

     

574错误软件包[CSharpPackage]的LegacySitePackage失败源:'Microsoft.VisualStudio.LanguageServices'说明:无法加载文件或程序集'Microsoft.CodeAnalysis,版本= 2.10.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35'或一个它的依赖关系。该系统找不到指定的文件。 System.IO.FileNotFoundException:无法加载文件或程序集“ Microsoft.CodeAnalysis,版本= 2.10.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35”或其依赖项之一。该系统找不到指定的文件。文件名:Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractPackage`2.Initialize()处的Microsoft.CodeAnalysis,Version = 2.10.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35' Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp)上的.CSharpPackage.Initialize()WRN:程序集绑定日志记录已关闭。要启用程序集绑定失败日志记录,请将注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog](DWORD)设置为1。注意:程序集绑定失败日志记录会降低性能。要关闭此功能,请删除注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog]。 {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:50.413

     

575错误SetSite软件包CSharpPackage {13C3BBB4-F18F-4111-9F54-A0FB010D9194}失败80070002 VisualStudio 2019/04/08 11:04:50.413

     

576错误结束程序包加载[CSharpPackage] {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:50.413

     

614错误LegacySitePackage对于程序包[CSharpPackage]失败源:'Microsoft.VisualStudio.LanguageServices'说明:无法加载文件或程序集'Microsoft.CodeAnalysis,版本= 2.10.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35'或一个它的依赖关系。该系统找不到指定的文件。 System.IO.FileNotFoundException:无法加载文件或程序集“ Microsoft.CodeAnalysis,版本= 2.10.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35”或其依赖项之一。该系统找不到指定的文件。文件名:Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractPackage`2.Initialize()处的Microsoft.CodeAnalysis,Version = 2.10.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35' Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp)上的.CSharpPackage.Initialize()WRN:程序集绑定日志记录已关闭。要启用程序集绑定失败日志记录,请将注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog](DWORD)设置为1。注意:程序集绑定失败日志记录会降低性能。要关闭此功能,请删除注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog]。 {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:51.586

     

615软件包CSharpPackage {13C3BBB4-F18F-4111-9F54-A0FB010D9194}的SetSite失败80070002 VisualStudio 2019/04/08 11:04:51.592

     

616错误结束程序包加载[CSharpPackage] {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:51.596

     

641错误无法加载扩展名,因为具有相同ID'Microsoft.Windows.DevelopmentKit.Desktop'的扩展名已经在C:\ PROGRAM FILES(X86)\ COMMON FILES \ MICROSOFT \ EXTENSIONMANAGER \ EXTENSIONS \ MICROSOFT \ WINDOWS KITS \ 10 \ DESKTOP SDK ...             C:\ PROGRAM FILES(X86)\ COMMON FILES \ MICROSOFT \ EXTENSIONMANAGER \ EXTENSIONS \ MICROSOFT \ WINDOWS KITS \ 8.1 \ DESKTOP SDK \ Extension Manager 2019/04/08 11:04:51.967

     

642错误扩展名不会被加载,因为具有相同ID'Microsoft.Windows.DevelopmentKit.WindowsStore'的扩展名已经在C:\ PROGRAM FILES(X86)\ COMMON FILES \ MICROSOFT \ EXTENSIONMANAGER \ EXTENSIONS \ MICROSOFT \ WINDOWS套件\ 10 \ WINDOWS STORE SDK ...             C:\ PROGRAM FILES(X86)\ COMMON FILES \ MICROSOFT \ EXTENSIONMANAGER \ EXTENSIONS \ MICROSOFT \ WINDOWS KITS \ 8.1 \ WINDOWS STORE SDK \ Extension Manager 2019/04/08 11:04:51.968

     

661错误MEF组件在运行时引发异常:Microsoft.VisualStudio.Composition.CompositionFailedException:初始化部件“ Microsoft.CodeAnalysis.Diagnostics.DiagnosticService”时引发了异常。 ---> System.IO.FileNotFoundException:无法加载文件或程序集'Microsoft.CodeAnalysis,版本= 2.10.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。该系统找不到指定的文件。在Microsoft.CodeAnalysis.Diagnostics.DiagnosticService..ctor(IAsynchronousOperationListenerProvider listenerProvider)-内部异常堆栈跟踪结束--在Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()在Microsoft.VisualStudio.Composition。 Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)处的ExportProvider.PartLifecycleTracker.Create()Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker处的Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState)处的ExportProvider.PartLifecycleTracker.Create()。 Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider上的GetValueReadyToExpose()。<> c__DisplayClass15_0.b__0()Microsoft.VisualStudio.ComponentModelHost.VsShellComponentModelHost 2019/04/08 11:04:53.135

     

662错误,MEF组件在运行时引发了异常:Microsoft.VisualStudio.Composition.CompositionFailedException:初始化部件“ Microsoft.CodeAnalysis.Diagnostics.DiagnosticService”时引发了异常。 ---> System.IO.FileNotFoundException:无法加载文件或程序集'Microsoft.CodeAnalysis,版本= 2.10.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。该系统找不到指定的文件。在Microsoft.CodeAnalysis.Diagnostics.DiagnosticService..ctor(IAsynchronousOperationListenerProvider listenerProvider)-从先前引发异常的位置开始的堆栈跟踪-在Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(ExceptionExceptionObject)- -内部异常堆栈跟踪的结尾---在Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()在Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()在Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState。 __DisplayClass15_0.b__0(),位于Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importingPartTracker,RuntimeImport导入,RuntimeExport导出,Func 3 lazyFactory) at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import) at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.<CreateValue>b__10_0(RuntimeImport import) at System.Linq.Enumerable.WhereSelectArrayIterator 2.System.Linq.Buffer 1..ctor(IEnumerable 1 Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()上System.Linq.Enumerable.ToArray [TSource](IEnumerable`1源)上Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue() Microsoft.VisualStudio.com上的Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState)处的Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)Microsoft.VisualStudio处的Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose() Composition.RuntimeExportProviderFactory.RuntimeExportProvider。<> c__Disp layClass15_0.b__0()Microsoft.VisualStudio.ComponentModelHost.VsShellComponentModelHost 2019/04/08 11:04:53.140

     

711错误Microsoft.VisualStudio.Composition.CompositionFailedException:初始化部件“ Microsoft.CodeAnalysis.Diagnostics.DiagnosticService”时引发了异常。 ---> System.IO.FileNotFoundException:无法加载文件或程序集'Microsoft.CodeAnalysis,版本= 2.10.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。该系统找不到指定的文件。在Microsoft.CodeAnalysis.Diagnostics.DiagnosticService..ctor(IAsynchronousOperationListenerProvider listenerProvider)-从先前引发异常的位置开始的堆栈跟踪-在Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(ExceptionExceptionObject)- -在Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)处从上一个引发异常的位置开始的堆栈跟踪-在Microsoft处从上一个引发异常的先前位置的堆栈跟踪.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)-内部异常堆栈跟踪的结尾--在Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()在Microsoft.VisualStudio.Composition.ExportProvider Microsoft.VisualSt上的.PartLifecycleTracker.Create() Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)的Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()的udio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState) Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importPartTracker,RuntimeImport import,RuntimeExport export,Func 3 lazyFactory) at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import) at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.<CreateValue>b__10_0(RuntimeImport import) at System.Linq.Enumerable.WhereSelectArrayIterator 2.Moveinq()上的RuntimeExportProviderFactory.RuntimeExportProvider。<> c__DisplayClass15_0.b__0()在Microsoft.VisualStudio.Composition。 System.Linq.Enumerable.ToArray [TSource](IEnumerable 1..ctor(IEnumerable 1.b__0()在System.Lazy 1 source) at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue() at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create() at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState) at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState) at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose() at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.<>c__DisplayClass15_0.<GetExportedValueHelper>b__0() at Microsoft.VisualStudio.Composition.DelegateServices.<>c__DisplayClass2_0 1.LazyInitValue()在System.Lazy { {1}} 1.GatherTaggers(ITextBuffer textBuffer)编辑器或编辑器扩展

>

我卸载了重新安装的Visual Studio组件,更新了unity,并统一创建了一个新项目,删除了文件和文件夹以及其他内容,

此后:https://docs.microsoft.com/en-us/visualstudio/cross-platform/getting-started-with-visual-studio-tools-for-unity?view=vs-2017

这是https://developercommunity.visualstudio.com/content/problem/8536/unexpected-system-error-mode-before-loading-packag.html

这是Error message "No exports were found that match the constraint contract name"

https://answers.unity.com/questions/1243747/visual-studio-error.html

输出窗口错误的详细信息是:“ C:... \ unity \ f1febc1088bcc6547ad7f93828b356f1 \ sprint 02 \ Assembly-CSharp.csproj:错误:无法打开项目'Assembly-CSharp',因为Visual C#2017编译器无法被创建。错误HRESULT E_FAIL已从对COM组件的调用返回。”

我正在运行Visual Studio Enterprise 2017 15.9.11版和

个人版本2018.3.11f1。

启用了适用于Unity 3.9.0.3的Microsoft Visual Studio工具

1 个答案:

答案 0 :(得分:0)

我卸载了VS企业版并安装了VS社区。然后,我可以通过统一打开VS来编辑代码。我想知道为什么它应该在VS企业版和社区版之间有所作为,所以我卸载了社区版,然后重新安装了企业版。而且..它起作用了。回顾一下:卸载并重新安装Visual Studio解决了我的问题。