ERROR: Multiple ambiguous overloads found for [System.Drawing.Font]::new and the argument count: "3"

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.
User avatar
ALIENQuake
Posts: 59
Joined: Sun Mar 03, 2013 12:45 pm

ERROR: Multiple ambiguous overloads found for [System.Drawing.Font]::new and the argument count: "3"

Post by ALIENQuake »

Powershell Studio 2020 5.7.175 64 bit
Microsoft Windows 10.0.19555 64 bit

My treeView control has font set. After upgrade to 175, the font cannot be set and I'm getting this error when I'm launching form:

Code: Select all

ERROR: Multiple ambiguous overloads found for "new" and the argument count: "3".
....Run.ps1 (14519, 2): ERROR: At Line: 14519 char: 2
ERROR: +     $treeView.Font = [System.Drawing.Font]::new('Segoe UI ...
ERROR: +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR:     + CategoryInfo          : NotSpecified: (:) [], MethodException
ERROR:     + FullyQualifiedErrorId : MethodCountCouldNotFindBest
This is the part of the '...export.run.ps1' file:

Code: Select all

$treeView.DrawMode = 'OwnerDrawText'
$treeView.Font = [System.Drawing.Font]::new('Segoe UI', 8,25)
$treeView.HideSelection = $False
There are no quotes around 8,25 numbers. How I can fix this temporary on my end?

User avatar
brittneyr
Site Admin
Posts: 570
Joined: Thu Jun 01, 2017 7:20 am
Answers: 1

Re: ERROR: Multiple ambiguous overloads found for [System.Drawing.Font]::new and the argument count: "3"

Post by brittneyr »

Thank you for reporting this. Can you tell me what font properties you have set for your $treeView control from the designer?
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
ALIENQuake
Posts: 59
Joined: Sun Mar 03, 2013 12:45 pm

Re: ERROR: Multiple ambiguous overloads found for [System.Drawing.Font]::new and the argument count: "3"

Post by ALIENQuake »

Hi, I've set 'Bold'.

User avatar
brittneyr
Site Admin
Posts: 570
Joined: Thu Jun 01, 2017 7:20 am
Answers: 1

Re: ERROR: Multiple ambiguous overloads found for [System.Drawing.Font]::new and the argument count: "3"

Post by brittneyr »

I've been able to reproduce this behavior and have informed the development team. The issue seems to only appear when you set a font style. This should be resolved in the next release of PowerShell Studio. For a temporary fix, update the line to:
  1. [System.Drawing.Font]::New('Segoe UI', 8.25, [System.Drawing.FontStyle]'Bold')
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
ALIENQuake
Posts: 59
Joined: Sun Mar 03, 2013 12:45 pm

Re: ERROR: Multiple ambiguous overloads found for [System.Drawing.Font]::new and the argument count: "3"

Post by ALIENQuake »

brittneyr wrote:
Mon May 04, 2020 7:44 am
I've been able to reproduce this behavior and have informed the development team. The issue seems to only appear when you set a font style. This should be resolved in the next release of PowerShell Studio. For a temporary fix, update the line to:
  1. [System.Drawing.Font]::New('Segoe UI', 8.25, [System.Drawing.FontStyle]'Bold')
The context of what is actually broken:
I set the font style to bold in order to workaround 'Winforms bold treeview node doesn't show the whole text' problem.

I can't update the 'exported' code of the entire project. I could fix this inside psf but it is obfuscated. I guess I have to fix this via code itself.

User avatar
brittneyr
Site Admin
Posts: 570
Joined: Thu Jun 01, 2017 7:20 am
Answers: 1

Re: ERROR: Multiple ambiguous overloads found for [System.Drawing.Font]::new and the argument count: "3"

Post by brittneyr »

This issue has been resolved. The fix should be released soon.
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
brittneyr
Site Admin
Posts: 570
Joined: Thu Jun 01, 2017 7:20 am
Answers: 1

Re: ERROR: Multiple ambiguous overloads found for [System.Drawing.Font]::new and the argument count: "3"

Post by brittneyr »

Please try the latest service release (5.7.176) and let me know if this issue still persists.
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
ALIENQuake
Posts: 59
Joined: Sun Mar 03, 2013 12:45 pm

Re: ERROR: Multiple ambiguous overloads found for [System.Drawing.Font]::new and the argument count: "3"

Post by ALIENQuake »

Well, now it's even worse:

the problem lies with font size:

Code: Select all

$treeview1.Font = [System.Drawing.Font]::new('Segoe UI', '8,25', [System.Drawing.FontStyle]'Bold')
If the font-size value has a comma, it is treated differently when it is an only a single number.

Image
Attachments
BoldError.zip
(8.49 KiB) Downloaded 35 times

User avatar
brittneyr
Site Admin
Posts: 570
Joined: Thu Jun 01, 2017 7:20 am
Answers: 1

Re: ERROR: Multiple ambiguous overloads found for [System.Drawing.Font]::new and the argument count: "3"

Post by brittneyr »

Service build 5.7.177 should fix the latest issue in regards to the font not working. I apologize for the inconvenience of this. If there is any more issues, please let me know.
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
ALIENQuake
Posts: 59
Joined: Sun Mar 03, 2013 12:45 pm

Re: ERROR: Multiple ambiguous overloads found for [System.Drawing.Font]::new and the argument count: "3"

Post by ALIENQuake »

It works, thanks for the quick fix.