Import-LocalizedData error with Windows Forms Designer

Issue #115 resolved
Jamie Beck created an issue

In Forms Designer after importing an image and an icon to use with my main form, I receive restricted language mode errors when designer tries to import-localizeddata. This form has existed for awhile and it always worked correctly when the $Resource Variable was set using Invoke-Expression. I'm not sure in which version of the tools the method of getting that local data was changed but since then I get an error in my powershell window and the image and icon do not show up on the main form. This behavior is observable on all Forms I have created with Powershell tools as I use the same icon and a similar image in each one.

Visual Studio Professional 2017 Version 15.9.11 PowerShell Tools Version 4.4.0 PSVersion 5.1.17763.316 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.17763.316 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

The error is below.

Import-LocalizedData : The following error occurred while Windows PowerShell was loading the 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\tyli\Enable-User.GUI.resources.psd1' script data file: At line:2 char:27 + ... undImage' = New-Object -TypeName System.Drawing.Bitmap -ArgumentList ... + ~~~~~~~~~~~ The command 'New-Object' is not allowed in restricted language mode or a Data section. At line:2 char:86 + ... umentList @(New-Object -TypeName System.IO.MemoryStream -ArgumentLis ... + ~~~~~~~~~~~ The command 'New-Object' is not allowed in restricted language mode or a Data section. At line:2 char:148 + ... mentList @(,[System.Convert]::FromBase64String('R0lGODlhsgIyAIQfALe3r ... + ~~~~~~~~~~~ Method calls are not allowed in restricted language mode or a Data section. At line:2 char:148 + ... ame System.IO.MemoryStream -ArgumentList @(,[System.Convert]::FromBa ... + ~~~~ The type System.Convert is not allowed in restricted language mode or a Data section. At line:78 char:16 + ... his.Icon' = New-Object -TypeName System.Drawing.Icon -ArgumentList @( ... + ~~~~~~~~~~~ The command 'New-Object' is not allowed in restricted language mode or a Data section. At line:78 char:73 + ... umentList @(New-Object -TypeName System.IO.MemoryStream -ArgumentLis ... + ~~~~~~~~~~~ The command 'New-Object' is not allowed in restricted language mode or a Data section. At line:78 char:135 + ... mentList @(,[System.Convert]::FromBase64String('AAABAAEAAAAAAAAACAAoJ ... + ~~~~~~~~~~~ Method calls are not allowed in restricted language mode or a Data section. At line:78 char:135 + ... ame System.IO.MemoryStream -ArgumentList @(,[System.Convert]::FromBa ... + ~~~~ The type System.Convert is not allowed in restricted language mode or a Data section.. At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\tyli\Enable-User.GUI.designer.ps1:26 char:1 + Import-LocalizedData -BaseDirectory $PSScriptRoot -FileName 'Enable- ... + ~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Import-LocalizedData], PSInvalidOperationException + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ImportLocalizedData

Comments (3)

  1. Log in to comment