Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find type [System.Windows.Media.Stretch] #27

Closed
Agazoth opened this issue Nov 3, 2021 · 6 comments
Closed

Unable to find type [System.Windows.Media.Stretch] #27

Agazoth opened this issue Nov 3, 2021 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@Agazoth
Copy link

Agazoth commented Nov 3, 2021

Problem Report

Show-GuiCalendar does not work (on my machine)

What is the syntax or expression you are using?

Show-GuiCalendar 12/2018 2/2019 -highlight 12/24/18,12/25/18,12/31/18,1/1/19,1/18/19,2/14/19,2/22/19

What Happens?

InvalidOperation: C:\Users\axel\Documents\PowerShell\Modules\PSCalendar\2.3.2\functions\public.ps1:160
Line |
 160 |          [System.Windows.Media.Stretch]$Stretch = "UniformToFill",
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Unable to find type [System.Windows.Media.Stretch].



Unable to find type [System.Windows.Media.Stretch].
At C:\Users\axel\Documents\WindowsPowerShell\Modules\PSCalendar\2.3.2\functions\public.ps1:160 char:9
+         [System.Windows.Media.Stretch]$Stretch = "UniformToFill",
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Windows.Media.Stretch:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

What do you think should happen?

A GUI calendar should open

Environment Information

Name                           Value
----                           -----
PSVersion                      5.1.22000.282
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22000.282
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Name                           Value
----                           -----
PSVersion                      7.1.5
PSEdition                      Core
GitCommitId                    7.1.5
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


PS> $PSCulture
da-DK

PS> $PSUICulture
en-US

PS> Get-Module PSCalendar

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.3.2                 PSCalendar                          {Get-Calendar, Get-MonthName, Get-NCalendar, Get-P
@jdhitsolutions
Copy link
Owner

It is very possible that the necessary .NET classes are not part of .NET core in PowerShell 7. I'm assuming if you run the command in Windows PowerShell it works just fine. I may have to refactor the module not to export Show-GUICalendar for PowerShell 7.

@jdhitsolutions jdhitsolutions self-assigned this Nov 3, 2021
@jdhitsolutions jdhitsolutions added the bug Something isn't working label Nov 3, 2021
@jdhitsolutions
Copy link
Owner

Looks like a limitation in PowerShell 7. The .NET class works fine in Windows PowerShell.
image

But is missing in PowerShell 7
image

@jdhitsolutions
Copy link
Owner

Because this is a .NET limitation, obviously I can't fix it. I've updated the module and v2.4.0 no longer exports this command in PowerShell 7. That's the best I can do.

@Agazoth
Copy link
Author

Agazoth commented Nov 3, 2021

It is actually the same in Windows Powershell. I included the error from both.

@jdhitsolutions
Copy link
Owner

I missed that. That shouldn't be the case. I have never had an issue in Windows PowerShell (testing on multiple systems), but I got the same problem on PowerShell 7. Given that .NET Core is a subset of the .NET Framework in Windows PowerShell, this doesn't surprise me.

I can't think why this would fail in Windows PowerShell. Are you running something like a Home or Student edition? Not that it should make a difference. I can't imagine the Danish culture is causing a problem.

Update the module to 2.4.0 and try again in Windows PowerShell. I changed a parameter to use a string instead of the .NET class. Let's see if you get the same error. The command definitely won't run in PowerShell 7.

@Agazoth
Copy link
Author

Agazoth commented Nov 3, 2021

I can confirm that it works in Windows PowerShell now. Thanks :-)

@Agazoth Agazoth closed this as completed Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants