Error after upgrading to PowerShell Studio 2018: Could not load file or assembly 'System.Management.Automation'

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
dsloderbeck
Posts: 2
Last visit: Tue Feb 13, 2024 2:17 pm

Error after upgrading to PowerShell Studio 2018: Could not load file or assembly 'System.Management.Automation'

Post by dsloderbeck »

Product, version and build: PowerShell Studio 2018 - 64-bit (Version 5.5.149.0)
Operating system: Windows 10 v1709 (64-bit)


I recently upgraded my PowerShell Studio installation (from PowerShell Studio 2015 to PowerShell Studio 2018), and now whenever I create a new project, or open an existing project, I always receive the following error message:
  1. Startup.pss: Could not load file or assembly 'System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
As mentioned, this is happening on all projects, and I have not made any modifications to the default "Startup.pss" file.

Also, if I look at the assemblies for the "Startup.pss", I see the following:

Missing Assembly.png
Missing Assembly.png (13.82 KiB) Viewed 2546 times
I was not receiving this error message when PowerShell Studio 2015 was installed. I've only started receiving this error after I upgraded to PowerShell Studio 2018.

For clarification, here is the "Startup.pss" that is being generated whenever I start a new project and receive this error message:

  1. #Define a Param block to use custom parameters in the project
  2. #Param ($CustomParameter)
  3.  
  4. function Main {
  5. <#
  6.     .SYNOPSIS
  7.         The Main function starts the project application.
  8.    
  9.     .PARAMETER Commandline
  10.         $Commandline contains the complete argument string passed to the script packager executable.
  11.    
  12.     .NOTES
  13.         Use this function to initialize your script and to call GUI forms.
  14.        
  15.     .NOTES
  16.         To get the console output in the Packager (Forms Engine) use:
  17.         $ConsoleOutput (Type: System.Collections.ArrayList)
  18. #>
  19.     Param ([String]$Commandline)
  20.        
  21.     #--------------------------------------------------------------------------
  22.     #TODO: Add initialization script here (Load modules and check requirements)
  23.    
  24.    
  25.     #--------------------------------------------------------------------------
  26.    
  27.     if((Show-MainForm_psf) -eq 'OK')
  28.     {
  29.        
  30.     }
  31.    
  32.     $script:ExitCode = 0 #Set the exit code for the Packager
  33. }
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Error after upgrading to PowerShell Studio 2018: Could not load file or assembly 'System.Management.Automation'

Post by davidc »

Simply remove the reference to System.Management.Automation. It is not necessary in later versions of PowerShell Studio.
David
SAPIEN Technologies, Inc.
User avatar
dsloderbeck
Posts: 2
Last visit: Tue Feb 13, 2024 2:17 pm

Re: Error after upgrading to PowerShell Studio 2018: Could not load file or assembly 'System.Management.Automation'

Post by dsloderbeck »

@davidc,

Thanks for your reply. Since this assembly is automatically added by PowerShell studio whenever I create a new project, I wasn't sure if it was necessary or not, so I didn't want to delete it without checking first. I'll go ahead and delete it now.
This topic is 6 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.