Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error running command csdevkit.addNewFile: The type initializer for 'HostData' threw an exception. #1689

Closed
jorgelaranjo opened this issue Dec 14, 2024 · 8 comments
Assignees
Labels
area-project Project load, Solution Explorer bug Something isn't working

Comments

@jorgelaranjo
Copy link

jorgelaranjo commented Dec 14, 2024

Describe the Issue

I can't add files from solution explorer from a simple project. Gives me this error:

Error running command csdevkit.addNewFile: The type initializer for 'HostData' threw an exception.. This is likely caused by the extension that contributes csdevkit.addNewFile.

Steps To Reproduce

No response

Expected Behavior

Creates file

Environment Information

  • VSCode: 1.95.3
  • OS: 6.12.1-arch1-1
  • SDK: 8.0.110
  • csdevkit v1.14.14
    Project is on Dotnet 8.0

Seems similar to #1000

@jorgelaranjo jorgelaranjo added the bug Something isn't working label Dec 14, 2024
@AbhitejJohn AbhitejJohn added the area-project Project load, Solution Explorer label Dec 16, 2024
@AbhitejJohn
Copy link

@adrianvmsft , @Michael-Eng : could you please help?

@Michael-Eng
Copy link
Member

@JakeRadMSFT can you take a look - could it be related to the template engine?

@jorgelaranjo
Copy link
Author

Log is

2024-12-17 11:38:23.606 [error] Error: The type initializer for '**HostData**' threw an exception.
    at ~/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:831486
    at ne (~/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:831780)
    at ~/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:826564
    at Immediate.<anonymous> (~/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:826584)
    at processImmediate (node:internal/timers:483:21) csdevkit.addNewFile {"value":"ms-dotnettools.csdevkit","_lower":"ms-dotnettools.csdevkit"}

However
File > New File... > .NET: New File...

Creates

namespace ConsoleApp1;

public class Class1
{
    
}

@LittleLittleCloud
Copy link

@jorgelaranjo Sorry I can't reproduce this bug on my end, would you mind sharing more details on how to reproduce this issue.

Regards

@jorgelaranjo
Copy link
Author

Bug not present anymore on latest version

Version: 1.96.2 (1.96.2-1)
Commit: fabdb6a30b49f79a7aba0f2ad9df9b399473380f
Date: 2024-12-19T10:22:47.216Z
Electron: 32.2.6
ElectronBuildId: 10629634
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Linux x64 6.12.4-arch1-1

@jorgelaranjo
Copy link
Author

jorgelaranjo commented Dec 29, 2024

Showing again. Based on logs, could be similar to #386
But after a few restarts of VSCode it works. I'd like to pinpoint the problem to avoid it.

Error running command csdevkit.addNewFile: The type initializer for 'HostData' threw an exception.. This is likely caused by the extension that contributes csdevkit.addNewFile.

Changed from Linux x64 6.12.4-arch1-1 to OS: Linux x64 6.12.6-arch1-1

Version: 1.96.2
Commit: fabdb6a30b49f79a7aba0f2ad9df9b399473380f
Date: 2024-12-19T10:22:47.216Z
Electron: 32.2.6
ElectronBuildId: 10629634
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Linux x64 6.12.**6**-arch1-1

Logs

2024-12-29 11:17:59.518 [info] Invalid Culture: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
en-us is an invalid culture identifier.

2024-12-29 11:18:02.201 [info] Project system initialization finished. 1 project(s) are loaded, and 0 failed to load.
2024-12-29 11:17:49.361 [info] ExtensionService#_doActivateExtension ms-dotnettools.csdevkit, startup: true, activationEvent: 'workspaceContains:**/*.csproj'
2024-12-29 11:17:49.361 [trace] ExtensionService#loadCommonJSModule file:///home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js
2024-12-29 11:17:49.361 [trace] ExtensionService#loadExtensionContext ms-dotnettools.csdevkit
2024-12-29 11:17:49.504 [trace] ExtensionService#_callActivateOptional ms-dotnettools.csdevkit
(...)
2024-12-29 11:18:08.792 [trace] ExtHostCommands#$executeContributedCommand csdevkit.addNewFile
    at /home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:831486
    at ne (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:831780)
    at /home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:826564
    at Immediate.<anonymous> (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:826584)
    at processImmediate (node:internal/timers:483:21) csdevkit.addNewFile {"value":"ms-dotnettools.csdevkit","_lower":"ms-dotnettools.csdevkit"}
2024-12-29 11:18:09.226 [trace] forwarded error to extension? true {"value":"ms-dotnettools.csdevkit","_lower":"ms-dotnettools.csdevkit"}
2024-12-29 11:18:13.263 [error] An error occurred when disposing the subscriptions for extension 'ms-dotnettools.csdevkit':
    at ue (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:833908)
    at Object.sendNotification (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:834751)
    at Proxy.dispose (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:196064)
    at ue (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:833908)
    at Object.sendRequest (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:835994)
    at t.invokeRpc (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:198536)
    at Proxy.<anonymous> (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:172127)
    at t.TestViewManager.dispose (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:226475)
    at _.dispose (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:234598)
2024-12-29 11:06:30.152 [error] Error: The type initializer for 'HostData' threw an exception.
    at /home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:831486
    at ne (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:831780)
    at /home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:826564
    at Immediate.<anonymous> (/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/dist/extension.js:2:826584)
    at processImmediate (node:internal/timers:483:21) csdevkit.addNewFile {"value":"ms-dotnettools.csdevkit","_lower":"ms-dotnettools.csdevkit"}
  3 79:12/29/2024 10:11:20 GMT : Information :     "/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/components/vs-code-coverage/platforms/linux-x64/node_modules/@microsoft/coverage-services.linux-x64/System.Runtime.dll" does not exist.                                                                                                                                                                       
  2 83:12/29/2024 10:11:20 GMT : Information :     "/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/components/vs-code-coverage/platforms/linux-x64/node_modules/@microsoft/coverage-services.linux-x64/System.Collections.dll" does not exist.                                                                                                                                                                   
  1 87:12/29/2024 10:11:20 GMT : Information :     "/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/components/vs-code-coverage/platforms/linux-x64/node_modules/@microsoft/coverage-services.linux-x64/System.Collections.Concurrent.dll" does not exist.                                                                                                                                                        
29  91:12/29/2024 10:11:20 GMT : Information :     "/home/user/.vscode/extensions/ms-dotnettools.csdevkit-1.14.14-linux-x64/components/vs-code-coverage/platforms/linux-x64/node_modules/@microsoft/coverage-services.linux-x64/System.Collections.dll" does not exist. 
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>10</EventID><Type>3</Type><SubType Name="Error">0</SubType><Level>2</Level><TimeCreated SystemTime="2024-12-29T10:11:52.4771446Z" /><Source Name="Microsoft.TemplateEngine.VSCode.TemplateService (0.1)" /><Correlation ActivityID="{0fa1c543-a069-420a-91bb-fdaf439affa2}" /><Execution ProcessName="Microsoft.VisualStudio.Code.Server" ProcessID="481048" ThreadID="20" /><Channel/><Computer>m75q-gen2</Computer></System><ApplicationData>Exception thrown from request &quot;1&quot; for method getProjectItemTemplates: System.AggregateException: One or more errors occurred. (The type initializer for &apos;HostData&apos; threw an exception.)&#xA; ---&gt; System.TypeInitializationException: The type initializer for &apos;HostData&apos; threw an exception.&#xA; ---&gt; System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter &apos;culture&apos;)&#xA;1033 (0x0409) is an invalid culture identifier.&#xA;   at System.Globalization.CultureData.GetCultureData(Int32 culture, Boolean bUseUserOverride)&#xA;   at System.Globalization.CultureInfo..ctor(Int32 culture, Boolean useUserOverride)&#xA;   at Microsoft.TemplateEngine.VSCode.Implementation.Shared.HostDataLoader.HostData..cctor()&#xA;   --- End of inner exception stack trace ---&#xA;   at Microsoft.TemplateEngine.VSCode.Implementation.Shared.HostDataLoader.HostData.LoadStrings(IEngineEnvironmentSettings env, String mountPointPlace, String basePath, String stringsFile)&#xA;   at System.Threading.LazyInitializer.EnsureInitializedCore[T](T&amp; target, Func`1 valueFactory)&#xA;   at Microsoft.TemplateEngine.VSCode.Implementation.Shared.DefaultPackageStringLoader.GetString(IHostPackageTextProperty packageText, String fallbackValue)&#xA;   at Microsoft.TemplateEngine.VSCode.Implementation.Shared.WrappedTemplate.&lt;get_Name&gt;b__10_0()&#xA;   at System.Threading.LazyInitializer.EnsureInitializedCore[T](T&amp; target, Func`1 valueFactory)&#xA;   at Microsoft.TemplateEngine.VSCode.Services.ItemTemplateInfo.Create(ITemplateGroup templateGroup)&#xA;   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()&#xA;   at Microsoft.TemplateEngine.VSCode.Implementation.TemplateService.GetProjectItemTemplatesAsync(String projectPath, CancellationToken cancellationToken)&#xA;   --- End of inner exception stack trace ---</ApplicationData></E2ETraceEvent>
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>10</EventID><Type>3</Type><SubType Name="Error">0</SubType><Level>2</Level><TimeCreated SystemTime="2024-12-29T10:11:52.4775478Z" /><Source Name="Microsoft.TemplateEngine.VSCode.TemplateService (0.1)" /><Correlation ActivityID="{0fa1c543-a069-420a-91bb-fdaf439affa2}" /><Execution ProcessName="Microsoft.VisualStudio.Code.Server" ProcessID="481048" ThreadID="20" /><Channel/><Computer>m75q-gen2</Computer></System><ApplicationData><TraceData><DataItem>System.AggregateException: One or more errors occurred. (The type initializer for &apos;HostData&apos; threw an exception.)&#xA; ---&gt; System.TypeInitializationException: The type initializer for &apos;HostData&apos; threw an exception.&#xA; ---&gt; System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter &apos;culture&apos;)&#xA;1033 (0x0409) is an invalid culture identifier.&#xA;   at System.Globalization.CultureData.GetCultureData(Int32 culture, Boolean bUseUserOverride)&#xA;   at System.Globalization.CultureInfo..ctor(Int32 culture, Boolean useUserOverride)&#xA;   at Microsoft.TemplateEngine.VSCode.Implementation.Shared.HostDataLoader.HostData..cctor()&#xA;   --- End of inner exception stack trace ---&#xA;   at Microsoft.TemplateEngine.VSCode.Implementation.Shared.HostDataLoader.HostData.LoadStrings(IEngineEnvironmentSettings env, String mountPointPlace, String basePath, String stringsFile)&#xA;   at System.Threading.LazyInitializer.EnsureInitializedCore[T](T&amp; target, Func`1 valueFactory)&#xA;   at Microsoft.TemplateEngine.VSCode.Implementation.Shared.DefaultPackageStringLoader.GetString(IHostPackageTextProperty packageText, String fallbackValue)&#xA;   at Microsoft.TemplateEngine.VSCode.Implementation.Shared.WrappedTemplate.&lt;get_Name&gt;b__10_0()&#xA;   at System.Threading.LazyInitializer.EnsureInitializedCore[T](T&amp; target, Func`1 valueFactory)&#xA;   at Microsoft.TemplateEngine.VSCode.Services.ItemTemplateInfo.Create(ITemplateGroup templateGroup)&#xA;   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()&#xA;   at Microsoft.TemplateEngine.VSCode.Implementation.TemplateService.GetProjectItemTemplatesAsync(String projectPath, CancellationToken cancellationToken)&#xA;   --- End of inner exception stack trace ---</DataItem><DataItem>getProjectItemTemplates</DataItem><DataItem>1</DataItem><DataItem></DataItem></TraceData></ApplicationData></E2ETraceEvent>
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>0</EventID><Type>3</Type><SubType Name="Stop">0</SubType><Level>255</Level><TimeCreated SystemTime="2024-12-29T10:11:52.4778368Z" /><Source Name="Microsoft.TemplateEngine.VSCode.TemplateService (0.1)" /><Correlation ActivityID="{0fa1c543-a069-420a-91bb-fdaf439affa2}" /><Execution ProcessName="Microsoft.VisualStudio.Code.Server" ProcessID="481048" ThreadID="20" /><Channel/><Computer>m75q-gen2</Computer></System><ApplicationData>getProjectItemTemplates</ApplicationData></E2ETraceEvent><E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"><EventID>8</EventID><Type>3</Type><SubType Name="Information">0</SubType><Level>8</Level><TimeCreated SystemTime="2024-12-29T10:11:52.4898897Z" /><Source Name="Microsoft.TemplateEngine.VSCode.TemplateService (0.1)" /><Correlation ActivityID="{f118a557-3c95-4f12-b210-0f991a60fde9}" /><Execution ProcessName="Microsoft.VisualStudio.Code.Server" ProcessID="481048" ThreadID="20" /><Channel/><Computer>m75q-gen2</Computer></System><ApplicationData><TraceData><DataItem>{&quot;id&quot;:1,&quot;error&quot;:{&quot;code&quot;:-32000,&quot;message&quot;:&quot;The type initializer for &apos;HostData&apos; threw an exception.&quot;}}</DataItem></TraceData></ApplicationData></E2ETraceEvent>

@jorgelaranjo jorgelaranjo reopened this Dec 29, 2024
@jorgelaranjo
Copy link
Author

Additional log

2024-12-31 11:26:54.493 [info] Using dotnet configured on PATH
2024-12-31 11:26:54.494 [info] Dotnet path: /usr/share/dotnet/dotnet
2024-12-31 11:26:54.494 [info] Activating C# + C# Dev Kit...
2024-12-31 11:26:58.469 [info] [stdout] {"pipeName":"/tmp/8b81eeaa.sock"}

2024-12-31 11:26:58.469 [info] received named pipe information from server
2024-12-31 11:26:59.166 [info] client has connected to server
2024-12-31 11:26:59.387 [info] [Info  - 11:26:59] [Program] Language server initialized
2024-12-31 11:27:00.122 [info] [Warn  - 11:27:00] [LanguageServerHost] Culture en was not found, falling back to OS culture

@jorgelaranjo
Copy link
Author

Root Cause:
The issue occurred because DOTNET_SYSTEM_GLOBALIZATION_INVARIANT was set to 1, disabling full globalization support.

Resolution:
Unset DOTNET_SYSTEM_GLOBALIZATION_INVARIANT or set it to 0 to enable proper functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-project Project load, Solution Explorer bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants