@@ -154,6 +154,8 @@ public void StartLogging(string logFilePath, LogLevel logLevel)
154
154
155
155
string osVersion = RuntimeInformation . OSDescription ;
156
156
157
+ string osArch = GetOSArchitecture ( ) ;
158
+
157
159
string buildTime = BuildInfo . BuildTime ? . ToString ( "s" , System . Globalization . CultureInfo . InvariantCulture ) ?? "<unspecified>" ;
158
160
159
161
string logHeader = $@ "
@@ -164,12 +166,12 @@ public void StartLogging(string logFilePath, LogLevel logLevel)
164
166
Name: { this . hostDetails . Name }
165
167
Version: { this . hostDetails . Version }
166
168
ProfileId: { this . hostDetails . ProfileId }
167
- Arch: { RuntimeInformation . OSArchitecture }
169
+ Arch: { osArch }
168
170
169
171
Operating system details:
170
172
171
173
Version: { osVersion }
172
- Arch: { RuntimeInformation . OSArchitecture }
174
+ Arch: { osArch }
173
175
174
176
Build information:
175
177
@@ -245,7 +247,7 @@ await this.editorSession.PowerShellContext.ImportCommandsModule(
245
247
// gets initialized when that is done earlier than LanguageServer.Initialize
246
248
foreach ( string module in this . additionalModules )
247
249
{
248
- var command =
250
+ var command =
249
251
new System . Management . Automation . PSCommand ( )
250
252
. AddCommand ( "Microsoft.PowerShell.Core\\ Import-Module" )
251
253
. AddParameter ( "Name" , module ) ;
@@ -493,6 +495,28 @@ private IServerListener CreateServiceListener(MessageProtocolType protocol, Edit
493
495
}
494
496
}
495
497
498
+ /// <summary>
499
+ /// Gets the OSArchitecture for logging. Cannot use System.Runtime.InteropServices.RuntimeInformation.OSArchitecture
500
+ /// directly, since this tries to load API set DLLs in win7 and crashes.
501
+ ///
502
+ /// <returns></returns>
503
+ private string GetOSArchitecture ( )
504
+ {
505
+ #if ! CoreCLR
506
+ // If on win7 (version 6.1.x), avoid System.Runtime.InteropServices.RuntimeInformation
507
+ if ( Environment . OSVersion . Platform == PlatformID . Win32NT && Environment . OSVersion . Version < new Version ( 6 , 2 ) )
508
+ {
509
+ if ( Environment . Is64BitProcess )
510
+ {
511
+ return "X64" ;
512
+ }
513
+
514
+ return "X86" ;
515
+ }
516
+ #endif
517
+ return RuntimeInformation . OSArchitecture . ToString ( ) ;
518
+ }
519
+
496
520
#endregion
497
521
}
498
522
}
0 commit comments