Skip to content

Commit 4494bb4

Browse files
author
Robert Holt
committed
Win7 OSArchitecture crash workaround
1 parent bb65b2a commit 4494bb4

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/PowerShellEditorServices.Host/EditorServicesHost.cs

+15-3
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ public void StartLogging(string logFilePath, LogLevel logLevel)
156156

157157
string buildTime = BuildInfo.BuildTime?.ToString("s", System.Globalization.CultureInfo.InvariantCulture) ?? "<unspecified>";
158158

159+
string osArch = GetOSArchitecture();
160+
159161
string logHeader = $@"
160162
PowerShell Editor Services Host v{fileVersionInfo.FileVersion} starting (PID {Process.GetCurrentProcess().Id}
161163
@@ -164,12 +166,12 @@ public void StartLogging(string logFilePath, LogLevel logLevel)
164166
Name: {this.hostDetails.Name}
165167
Version: {this.hostDetails.Version}
166168
ProfileId: {this.hostDetails.ProfileId}
167-
Arch: {RuntimeInformation.OSArchitecture}
169+
Arch: {osArch}
168170
169171
Operating system details:
170172
171173
Version: {osVersion}
172-
Arch: {RuntimeInformation.OSArchitecture}
174+
Arch: {osArch}
173175
174176
Build information:
175177
@@ -245,7 +247,7 @@ await this.editorSession.PowerShellContext.ImportCommandsModule(
245247
// gets initialized when that is done earlier than LanguageServer.Initialize
246248
foreach (string module in this.additionalModules)
247249
{
248-
var command =
250+
var command =
249251
new System.Management.Automation.PSCommand()
250252
.AddCommand("Microsoft.PowerShell.Core\\Import-Module")
251253
.AddParameter("Name", module);
@@ -493,6 +495,16 @@ private IServerListener CreateServiceListener(MessageProtocolType protocol, Edit
493495
}
494496
}
495497

498+
private static string GetOSArchitecture()
499+
{
500+
if (IntPtr.Size == 8)
501+
{
502+
return "X64";
503+
}
504+
505+
return "X86";
506+
}
507+
496508
#endregion
497509
}
498510
}

0 commit comments

Comments
 (0)