I have a very simple form with a label, a textbox and a button. When I run it and I try to introduce a text in the textbox it gets an error that it says:
>> Running (MapeigCorreccioExamenTS.psf) Script...
>> Platform: V4 64Bit (STA) (Elevated) (Forced)
ERROR: Method invocation failed because [System.Drawing.Font] does not contain a method named 'new'.
MapeigCorreccioExamenTS.Run.ps1 (136, 2): ERROR: At Line: 136 char: 2
ERROR: + $buttonAcceptar.Font = [System.Drawing.Font]::new('Arial Narrow', '8.25')
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : InvalidOperation: (:) [], RuntimeException
ERROR: + FullyQualifiedErrorId : MethodNotFound
ERROR:
ERROR: Method invocation failed because [System.Drawing.Font] does not contain a method named 'new'.
MapeigCorreccioExamenTS.Run.ps1 (147, 2): ERROR: At Line: 147 char: 2
ERROR: + $textbox1.Font = [System.Drawing.Font]::new('Courier New', '8.25')
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : InvalidOperation: (:) [], RuntimeException
ERROR: + FullyQualifiedErrorId : MethodNotFound
ERROR:
ERROR: Method invocation failed because [System.Drawing.Font] does not contain a method named 'new'.
MapeigCorreccioExamenTS.Run.ps1 (156, 2): ERROR: At Line: 156 char: 2
ERROR: + $labelEntraElDNIQueVolsCor.Font = [System.Drawing.Font]::new('Arial Narrow', '1 ...
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : InvalidOperation: (:) [], RuntimeException
ERROR: + FullyQualifiedErrorId : MethodNotFound
ERROR:
>> Script Ended
The code is
$form1_Load={
#TODO: Initialize Form Controls here
}
$labelEntraElDNIQueVolsCor_Click={
#TODO: Place custom script here
}
$buttonAcceptar_Click={
#TODO: Place custom script here
$user = $textbox1.Text
$File = Import-Csv \\alpicat\public\cpa\ExamenTS\DNITSAleatori.csv -Delimiter ";"
$File | ForEach-Object {
if ($_.DNI -like $user)
{
$folder = $_.Aleatori
}
}
$pathfolder = "\\ssvspospocpa9\ExamenTS\Prova" + "\" + $folder
net use L: /delete /y
net use M: /delete /y
net use L: \\ssvspospocpa9\ExamenTS\Materials
net use M: $PathFolder
}
We have installed PowerShell Studio 2021 version 5.8.187.0 and is running on a Windows 2012 R2 64 bits
Can you help us? Thanks!!!
Error in a textbox
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Error in a textbox
What version of PowerShell are you running this under?
The best way to detect the error is to paste the following into a PS shell.
add-type -AssemblyName system.drawing
[System.Drawing.Font]::new('Arial Narrow', '8.25')
The best way to detect the error is to paste the following into a PS shell.
add-type -AssemblyName system.drawing
[System.Drawing.Font]::new('Arial Narrow', '8.25')
- jramon.r@tv3.cat
- Posts: 25
- Last visit: Tue Jan 11, 2022 4:23 am
Re: Error in a textbox
We have installed PowerShell Studio 2021 version 5.8.187.0 and is running on a Windows 2012 R2 64 bits
I've pasted what you said and the message error is the same
"Method invocation failed because [System.Drawing.Font] does not contain a method named "new"
I've pasted what you said and the message error is the same
"Method invocation failed because [System.Drawing.Font] does not contain a method named "new"
- jramon.r@tv3.cat
- Posts: 25
- Last visit: Tue Jan 11, 2022 4:23 am
- jramon.r@tv3.cat
- Posts: 25
- Last visit: Tue Jan 11, 2022 4:23 am
Re: Error in a textbox
Yes. PS 5.1 will upgrade the net framework. YOU need to be sure 2012R2 is up to date or things will go wrong.
Note that 2012 is out of support so you may have many issues with updates and other problems. End of life was in 2018.
Note that 2012 is out of support so you may have many issues with updates and other problems. End of life was in 2018.
Re: Error in a textbox
Please follow these instructions and report the results.
[What version of PowerShell are you running this under?
The best way to detect the error is to paste the following into a PS shell (Not PowerShell Studio)
add-type -AssemblyName system.drawing
[System.Drawing.Font]::new('Arial Narrow', '8.25')
[What version of PowerShell are you running this under?
The best way to detect the error is to paste the following into a PS shell (Not PowerShell Studio)
add-type -AssemblyName system.drawing
[System.Drawing.Font]::new('Arial Narrow', '8.25')