title: How to solve RoselynPackage, CsharpPackage not loaded, C# 2022 language service could not be created. Value does not fall within the expected range
body: <p>After upgrading vs2019, and then also after installing vs2020 I can't open C# projects. Whenever I try to open I get first error boxes notifying that VS is not able to load the RoselynPackage and the CSharpPackage, and after that in output I get error message like this <em>project 'Assembly-CSharp' could not be opened because the Visual C# 2022 language service could not be created. Value does not fall within the expected range.</em></p>
  <p>Tried suggested method to delete \AppData\Local\Microsoft\VisualStudio\17.0_064520ec\ComponentModelCache and cleaning nuget etc (<a href="https://stackoverflow.com/questions/17574089/how-can-i-fix-the-microsoft-visual-studio-error-package-did-not-load-correctly">How can I fix the Microsoft Visual Studio error: &quot;package did not load correctly&quot;?</a>) cache but nothing seems to help.</p>
  <p>Also tried what is suggested here <a href="https://stackoverflow.com/questions/13361199/error-hresult-e-fail-has-been-returned-from-a-call-to-a-com-component-vs2012-whe/53097162">Error HRESULT E_FAIL has been returned from a call to a COM component VS2012 when debugging</a></p>
  <p>Tried to repair. Tried to clean visual studio and reinstall, did not help either.</p>
  <p>Found that if I create a new account on Windows and open visual studio from there, it works fine. Only in my account does it not work. Registry issue?</p>
  <p>This is what I get in activity log.</p>
  <pre><code>  &lt;entry&gt;
      &lt;record&gt;395&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.049&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;Begin package load [RoslynPackage]&lt;/description&gt;
      &lt;guid&gt;{6CF2E545-6109-4730-8883-CF43D7AEC3E1}&lt;/guid&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;396&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.058&lt;/time&gt;
      &lt;type&gt;Error&lt;/type&gt;
      &lt;source&gt;Microsoft.VisualStudio.LanguageServices.Setup.RoslynPackage&lt;/source&gt;
      &lt;description&gt;Exception occurred while loading solution options: System.Runtime.InteropServices.COMException (0x80030002):  could not be found. (Exception from HRESULT: 0x80030002 (STG_E_FILENOTFOUND))&amp;#x000D;&amp;#x000A;   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Shell.Package.Initialize()&amp;#x000D;&amp;#x000A;--- End of stack trace from previous location where exception was thrown ---&amp;#x000D;&amp;#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)&lt;/description&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;397&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.371&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;Begin package load [ErrorListPackage]&lt;/description&gt;
      &lt;guid&gt;{4A9B7E50-AA16-11D0-A8C5-00A0C921A4D2}&lt;/guid&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;398&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.395&lt;/time&gt;
      &lt;type&gt;Error&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;SetSite failed for package [RoslynPackage]Source: &amp;apos;mscorlib&amp;apos; Description: Illegal characters in path.&amp;#x000D;&amp;#x000A;System.ArgumentException: Illegal characters in path.&amp;#x000D;&amp;#x000A;   at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)&amp;#x000D;&amp;#x000A;   at System.IO.Path.Combine(String path1, String path2, String path3, String path4)&amp;#x000D;&amp;#x000A;   at Microsoft.CodeAnalysis.Internal.Log.FileLogger..ctor(IGlobalOptionService optionService)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.LanguageServices.Telemetry.VisualStudioWorkspaceTelemetryService.CreateLogger(TelemetrySession telemetrySession)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.LanguageServices.Telemetry.AbstractWorkspaceTelemetryService.InitializeTelemetrySession(TelemetrySession telemetrySession)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.LanguageServices.Setup.RoslynPackage.&amp;lt;InitializeAsync&amp;gt;d__19.MoveNext()&amp;#x000D;&amp;#x000A;--- End of stack trace from previous location where exception was thrown ---&amp;#x000D;&amp;#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#x000D;&amp;#x000A;   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Shell.AsyncPackage.&amp;lt;&amp;gt;c__DisplayClass20_0.&amp;lt;&amp;lt;Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize&amp;gt;b__1&amp;gt;d.MoveNext()&amp;#x000D;&amp;#x000A;--- End of stack trace from previous location where exception was thrown ---&amp;#x000D;&amp;#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#x000D;&amp;#x000A;   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Threading.JoinableTask.&amp;lt;JoinAsync&amp;gt;d__76.MoveNext()&amp;#x000D;&amp;#x000A;--- End of stack trace from previous location where exception was thrown ---&amp;#x000D;&amp;#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)&lt;/description&gt;
      &lt;guid&gt;{6CF2E545-6109-4730-8883-CF43D7AEC3E1}&lt;/guid&gt;
      &lt;hr&gt;80070057 - E_INVALIDARG&lt;/hr&gt;
      &lt;errorinfo&gt;&lt;/errorinfo&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;399&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.416&lt;/time&gt;
      &lt;type&gt;Error&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;End package load [RoslynPackage]&lt;/description&gt;
      &lt;guid&gt;{6CF2E545-6109-4730-8883-CF43D7AEC3E1}&lt;/guid&gt;
      &lt;hr&gt;80070057 - E_INVALIDARG&lt;/hr&gt;
      &lt;errorinfo&gt;&lt;/errorinfo&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;400&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.505&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;End package load [Microsoft.VisualStudio.PlatformUI.UIContextRules.ContextRuleMonitorPackage]&lt;/description&gt;
      &lt;guid&gt;{8AA75F1E-7410-4EFE-82AA-0FEA79A0A042}&lt;/guid&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;401&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.525&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;End package load [ErrorListPackage]&lt;/description&gt;
      &lt;guid&gt;{4A9B7E50-AA16-11D0-A8C5-00A0C921A4D2}&lt;/guid&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;402&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.612&lt;/time&gt;
      &lt;type&gt;Warning&lt;/type&gt;
      &lt;source&gt;GlobalBrokeredServiceContainer&lt;/source&gt;
      &lt;description&gt;Request for &amp;quot;Microsoft.VisualStudio.Shell.Internal.SettingsManager (1.0)&amp;quot; from Process denied because the service is only exposed RemoteExclusiveClient, LiveShareGuest.&lt;/description&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;403&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.612&lt;/time&gt;
      &lt;type&gt;Warning&lt;/type&gt;
      &lt;source&gt;GlobalBrokeredServiceContainer&lt;/source&gt;
      &lt;description&gt;Request for proxy to &amp;quot;Microsoft.VisualStudio.Shell.Internal.SettingsManager (1.0)&amp;quot; is declined: ServiceAudienceMismatch.&lt;/description&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;404&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.618&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;Begin package load [Microsoft.VisualStudio.Editor.Implementation.EditorPackage]&lt;/description&gt;
      &lt;guid&gt;{E269B994-EF71-4CE0-8BCD-581C217372E8}&lt;/guid&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;405&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.619&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;Begin package load [Global Hub Client Package]&lt;/description&gt;
      &lt;guid&gt;{11AD60FC-6D87-4674-8F88-9ABE79176CBE}&lt;/guid&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;406&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.688&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;Begin package load [Text Management Package]&lt;/description&gt;
      &lt;guid&gt;{F5E7E720-1401-11D1-883B-0000F87579D2}&lt;/guid&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;407&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.693&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;End package load [Text Management Package]&lt;/description&gt;
      &lt;guid&gt;{F5E7E720-1401-11D1-883B-0000F87579D2}&lt;/guid&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;408&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.811&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;End package load [Microsoft.VisualStudio.Editor.Implementation.EditorPackage]&lt;/description&gt;
      &lt;guid&gt;{E269B994-EF71-4CE0-8BCD-581C217372E8}&lt;/guid&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;409&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:34.876&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;End package load [Global Hub Client Package]&lt;/description&gt;
      &lt;guid&gt;{11AD60FC-6D87-4674-8F88-9ABE79176CBE}&lt;/guid&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;410&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:35.397&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;Extension Manager&lt;/source&gt;
      &lt;description&gt;IncompatibilityList - Call Servicehub for downloading compatibility list file.&lt;/description&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;411&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:35.844&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;Extension Manager&lt;/source&gt;
      &lt;description&gt;IncompatibilityList - Look for incompatible extensions.Configuration or the user compatibility list file changed&lt;/description&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;412&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:41.362&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;Begin package load [Microsoft.VisualStudio.Services.ToastNotifications.ToastNotificationsPackage]&lt;/description&gt;
      &lt;guid&gt;{C931D979-CA1A-41E8-8A23-E86B85E3141B}&lt;/guid&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;413&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:41.365&lt;/time&gt;
      &lt;type&gt;Information&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;End package load [Microsoft.VisualStudio.Services.ToastNotifications.ToastNotificationsPackage]&lt;/description&gt;
      &lt;guid&gt;{C931D979-CA1A-41E8-8A23-E86B85E3141B}&lt;/guid&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;414&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:43.821&lt;/time&gt;
      &lt;type&gt;Error&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;SetSite failed for package [CSharpPackage]Source: &amp;apos;Microsoft.VisualStudio.Interop&amp;apos; Description: Value does not fall within the expected range.&amp;#x000D;&amp;#x000A;System.ArgumentException: Value does not fall within the expected range.&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Shell.Interop.IVsTaskBody.DoWork(IVsTask pTask, UInt32 dwCount, IVsTask[] pParentTasks, Object&amp;amp; pResult)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.&amp;lt;&amp;gt;c__DisplayClass86_0.&amp;lt;GetCallbackForMultipleParent&amp;gt;b__0(Task`1[] _)&amp;#x000D;&amp;#x000A;   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()&amp;#x000D;&amp;#x000A;   at System.Threading.Tasks.Task.Execute()&amp;#x000D;&amp;#x000A;--- End of stack trace from previous location where exception was thrown ---&amp;#x000D;&amp;#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)&amp;#x000D;&amp;#x000A;--- End of stack trace from previous location where exception was thrown ---&amp;#x000D;&amp;#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractPackage`2.&amp;lt;InitializeAsync&amp;gt;d__5.MoveNext()&amp;#x000D;&amp;#x000A;--- End of stack trace from previous location where exception was thrown ---&amp;#x000D;&amp;#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#x000D;&amp;#x000A;   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage.&amp;lt;InitializeAsync&amp;gt;d__2.MoveNext()&amp;#x000D;&amp;#x000A;--- End of stack trace from previous location where exception was thrown ---&amp;#x000D;&amp;#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#x000D;&amp;#x000A;   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Shell.AsyncPackage.&amp;lt;&amp;gt;c__DisplayClass20_0.&amp;lt;&amp;lt;Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize&amp;gt;b__1&amp;gt;d.MoveNext()&amp;#x000D;&amp;#x000A;--- End of stack trace from previous location where exception was thrown ---&amp;#x000D;&amp;#x000A;   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Shell.UIThreadReentrancyScope.WaitOnTaskCompleteInternal(Task task, CancellationToken cancel, Int32 ms)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.&amp;lt;&amp;gt;c__DisplayClass68_1.&amp;lt;InternalGetResult&amp;gt;b__1()&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.IgnoreObjectDisposedException(Action action)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.&amp;lt;&amp;gt;c__DisplayClass68_0.&amp;lt;InternalGetResult&amp;gt;b__0()&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.&amp;lt;&amp;gt;c__DisplayClass76_0.&amp;lt;InvokeWithWaitDialog&amp;gt;b__0()&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.InvokeWithWaitDialog[T](Func`1 function)&amp;#x000D;&amp;#x000A;   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)&lt;/description&gt;
      &lt;guid&gt;{13C3BBB4-F18F-4111-9F54-A0FB010D9194}&lt;/guid&gt;
      &lt;hr&gt;80070057 - E_INVALIDARG&lt;/hr&gt;
      &lt;errorinfo&gt;&lt;/errorinfo&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
      &lt;record&gt;415&lt;/record&gt;
      &lt;time&gt;2022/01/17 10:48:43.832&lt;/time&gt;
      &lt;type&gt;Error&lt;/type&gt;
      &lt;source&gt;VisualStudio&lt;/source&gt;
      &lt;description&gt;End package load [CSharpPackage]&lt;/description&gt;
      &lt;guid&gt;{13C3BBB4-F18F-4111-9F54-A0FB010D9194}&lt;/guid&gt;
      &lt;hr&gt;80070057 - E_INVALIDARG&lt;/hr&gt;
      &lt;errorinfo&gt;&lt;/errorinfo&gt;
    &lt;/entry&gt;## Heading ##
  </code></pre>