0

Basically every time i try to open a c# file from unity i get:

message "one or more projects in the solution were not loaded correctly. please see the output window for details"

followed by "An exception has been encountered. This may be casued by an extension. you can get more information by examining the file ..." This file is really long so I will paste the errors only:

568 ERROR LegacySitePackage failed for package [CSharpPackage]Source: 'Microsoft.VisualStudio.LanguageServices' Description: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractPackage`2.Initialize() at Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage.Initialize() at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:50.397

569 ERROR SetSite failed for package CSharpPackage {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:50.403

570 ERROR End package load [CSharpPackage] {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:50.408

574 ERROR LegacySitePackage failed for package [CSharpPackage]Source: 'Microsoft.VisualStudio.LanguageServices' Description: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractPackage`2.Initialize() at Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage.Initialize() at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:50.413

575 ERROR SetSite failed for package CSharpPackage {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:50.413

576 ERROR End package load [CSharpPackage] {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:50.413

614 ERROR LegacySitePackage failed for package [CSharpPackage]Source: 'Microsoft.VisualStudio.LanguageServices' Description: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractPackage`2.Initialize() at Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage.Initialize() at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:51.586

615 ERROR SetSite failed for package CSharpPackage {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:51.592

616 ERROR End package load [CSharpPackage] {13C3BBB4-F18F-4111-9F54-A0FB010D9194} 80070002 VisualStudio 2019/04/08 11:04:51.596

641 ERROR Extension will not be loaded because an extension with the same ID 'Microsoft.Windows.DevelopmentKit.Desktop' is already loaded at 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 ERROR Extension will not be loaded because an extension with the same ID 'Microsoft.Windows.DevelopmentKit.WindowsStore' is already loaded at C:\PROGRAM FILES (X86)\COMMON FILES\MICROSOFT\EXTENSIONMANAGER\EXTENSIONS\MICROSOFT\WINDOWS KITS\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 ERROR A MEF Component threw an exception at runtime: Microsoft.VisualStudio.Composition.CompositionFailedException: An exception was thrown while initializing part "Microsoft.CodeAnalysis.Diagnostics.DiagnosticService". ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. at Microsoft.CodeAnalysis.Diagnostics.DiagnosticService..ctor(IAsynchronousOperationListenerProvider listenerProvider) --- End of inner exception stack trace --- 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.b__0() Microsoft.VisualStudio.ComponentModelHost.VsShellComponentModelHost 2019/04/08 11:04:53.135

662 ERROR A MEF Component threw an exception at runtime: Microsoft.VisualStudio.Composition.CompositionFailedException: An exception was thrown while initializing part "Microsoft.CodeAnalysis.Diagnostics.DiagnosticService". ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. at Microsoft.CodeAnalysis.Diagnostics.DiagnosticService..ctor(IAsynchronousOperationListenerProvider listenerProvider) --- End of stack trace from previous location where exception was thrown --- at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject) --- End of inner exception stack trace --- 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.b__0() at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import, RuntimeExport export, Func3 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.WhereSelectArrayIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`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.b__0() Microsoft.VisualStudio.ComponentModelHost.VsShellComponentModelHost 2019/04/08 11:04:53.140

711 ERROR Microsoft.VisualStudio.Composition.CompositionFailedException: An exception was thrown while initializing part "Microsoft.CodeAnalysis.Diagnostics.DiagnosticService". ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. at Microsoft.CodeAnalysis.Diagnostics.DiagnosticService..ctor(IAsynchronousOperationListenerProvider listenerProvider) --- End of stack trace from previous location where exception was thrown --- at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject) --- End of stack trace from previous location where exception was thrown --- at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject) --- End of stack trace from previous location where exception was thrown --- at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject) --- End of inner exception stack trace --- 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.b__0() at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import, RuntimeExport export, Func3 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.WhereSelectArrayIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 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_01.b__0() at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue() at System.Lazy1.get_Value() at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator1.GatherTaggers(ITextBuffer textBuffer) Editor or Editor Extension

>

I have uninstalled reinstalled visual studio compenents, updated unity and created a new projects in unity, deleted files and folders and other stuff by

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

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

and this: Error message "No exports were found that match the constraint contract name"

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

The output window error details is: "C:...\unity\f1febc1088bcc6547ad7f93828b356f1\sprint 02\Assembly-CSharp.csproj : error : Project 'Assembly-CSharp' could not be opened because the Visual C# 2017 compiler could not be created. Error HRESULT E_FAIL has been returned from a call to a COM component."

i am running visual studio enterprise 2017 version 15.9.11 and

unity version 2018.3.11f1 personal.

microsoft visual studio tools for unity 3.9.0.3 is enabled

  • if you are following https://learn.microsoft.com/en-us/visualstudio/cross-platform/getting-started-with-visual-studio-tools-for-unity?view=vs-2017 then you will have Visual studio community version. Try to change it from inside unity's preference settings. – Saad Anees Apr 08 '19 at 13:33
  • What components of VS did you install? Have you run VS outside unity? are you sure its not just sitting on the window saying how do you want to configure VS? – BugFinder Apr 08 '19 at 14:37
  • Saad - in Preferrences - External Tools the options I have are "open by File Extension", "Visual Studio 2017" or "Browse". BugFinder - I went to Visual Studio installer - modify - workloads and unchecked "Game Development with unity" clicked and clicked modify. After modification I went back in and checked "Game dev..." and modify. VS works fine when I use it on its own e.g. open it and then write code in C# or C++. The error windows in VS are informatitve and don't appear to be asking me how to configure. – combat womble Apr 08 '19 at 15:05

1 Answers1

0

I uninstalled VS enterprise and installed VS community. I was then able to open VS via unity to edit code. I wondered why it should make a difference between VS enterprise and community, so I uninstalled community and reinstalled enterprise. And .... it worked. So to recap: Uninstalling and reinstalling Visual Studio fixed my issue.