title: How to make Unity open Visual Studio 2017 to edit code
body: <p>Basically every time i try to open a c# file from unity i get:</p>
  
  <p>message "one or more projects in the solution were not loaded correctly. please see the output window for details"</p>
  
  <p>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:</p>
  
  <blockquote>
    <p>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</p>
    
    <p>569    ERROR   SetSite failed for package CSharpPackage    {13C3BBB4-F18F-4111-9F54-A0FB010D9194}  80070002    VisualStudio    2019/04/08 11:04:50.403</p>
    
    <p>570    ERROR   End package load [CSharpPackage]    {13C3BBB4-F18F-4111-9F54-A0FB010D9194}  80070002    VisualStudio    2019/04/08 11:04:50.408</p>
    
    <p>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</p>
    
    <p>575    ERROR   SetSite failed for package CSharpPackage    {13C3BBB4-F18F-4111-9F54-A0FB010D9194}  80070002    VisualStudio    2019/04/08 11:04:50.413</p>
    
    <p>576    ERROR   End package load [CSharpPackage]    {13C3BBB4-F18F-4111-9F54-A0FB010D9194}  80070002    VisualStudio    2019/04/08 11:04:50.413</p>
    
    <p>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</p>
    
    <p>615    ERROR   SetSite failed for package CSharpPackage    {13C3BBB4-F18F-4111-9F54-A0FB010D9194}  80070002    VisualStudio    2019/04/08 11:04:51.592</p>
    
    <p>616    ERROR   End package load [CSharpPackage]    {13C3BBB4-F18F-4111-9F54-A0FB010D9194}  80070002    VisualStudio    2019/04/08 11:04:51.596</p>
    
    <p>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</p>
    
    <p>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</p>
    
    <p>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.&lt;>c__DisplayClass15_0.b__0()            Microsoft.VisualStudio.ComponentModelHost.VsShellComponentModelHost 2019/04/08 11:04:53.135</p>
    
    <p>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.&lt;>c__DisplayClass15_0.b__0() at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import, RuntimeExport export, Func<code>3 lazyFactory) at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import) at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.&lt;CreateValue&gt;b__10_0(RuntimeImport import) at System.Linq.Enumerable.WhereSelectArrayIterator</code>2.MoveNext() at System.Linq.Buffer<code>1..ctor(IEnumerable</code>1 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.&lt;>c__DisplayClass15_0.b__0()            Microsoft.VisualStudio.ComponentModelHost.VsShellComponentModelHost 2019/04/08 11:04:53.140</p>
    
    <p>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.&lt;>c__DisplayClass15_0.b__0() at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportElement(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import, RuntimeExport export, Func<code>3 lazyFactory) at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import) at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.&lt;CreateValue&gt;b__10_0(RuntimeImport import) at System.Linq.Enumerable.WhereSelectArrayIterator</code>2.MoveNext() at System.Linq.Buffer<code>1..ctor(IEnumerable</code>1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable<code>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.&lt;&gt;c__DisplayClass15_0.&lt;GetExportedValueHelper&gt;b__0() at Microsoft.VisualStudio.Composition.DelegateServices.&lt;&gt;c__DisplayClass2_0</code>1.b__0() at System.Lazy<code>1.CreateValue() at System.Lazy</code>1.LazyInitValue() at System.Lazy<code>1.get_Value() at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator</code>1.GatherTaggers(ITextBuffer textBuffer)           Editor or Editor Extension</p>
  </blockquote>
  
  <p>></p>
  
  <p>I have uninstalled reinstalled visual studio compenents, updated unity and created a new projects in unity, deleted files and folders and other stuff by</p>
  
  <p>following this: <a href="https://docs.microsoft.com/en-us/visualstudio/cross-platform/getting-started-with-visual-studio-tools-for-unity?view=vs-2017" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/visualstudio/cross-platform/getting-started-with-visual-studio-tools-for-unity?view=vs-2017</a></p>
  
  <p>and this: <a href="https://developercommunity.visualstudio.com/content/problem/8536/unexpected-system-error-mode-before-loading-packag.html" rel="nofollow noreferrer">https://developercommunity.visualstudio.com/content/problem/8536/unexpected-system-error-mode-before-loading-packag.html</a></p>
  
  <p>and this: <a href="https://stackoverflow.com/questions/17596543/error-message-no-exports-were-found-that-match-the-constraint-contract-name/17604007#17604007">Error message &quot;No exports were found that match the constraint contract name&quot;</a></p>
  
  <p>​and this: <a href="https://answers.unity.com/questions/1243747/visual-studio-error.html" rel="nofollow noreferrer">https://answers.unity.com/questions/1243747/visual-studio-error.html</a></p>
  
  <p>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."</p>
  
  <p>i am running visual studio enterprise 2017 version 15.9.11 and</p>
  
  <p>unity version 2018.3.11f1 personal.</p>
  
  <p>microsoft visual studio tools for unity 3.9.0.3 is enabled</p>