Hello together I have an Issue with the WPF on VSCode
When I use the Following PS Code:
[System.Reflection.Assembly]::LoadWithPartialName("PresentationFramework") | Out-Null
function Import-Xaml {
[xml]$xaml = Get-Content -Path $PSScriptRoot\window.xaml
$manager = New-Object System.Xml.XmlNamespaceManager -ArgumentList $xaml.NameTable
$manager.AddNamespace("x", "http://schemas.microsoft.com/winfx/2006/xaml");
$xamlReader = New-Object System.Xml.XmlNodeReader $xaml
[Windows.Markup.XamlReader]::Load($xamlReader)
}
$Window = Import-Xaml
$window.ShowDialog()
I get the Following Error Message on the Console:
Exception calling "Load" with "1" argument(s): "Cannot set unknown member '{http://schemas.openxmlformats.org/markup-compatibility/2006}Ignorable'."
At H:\Powershell\Flow Rechner\Flow Calculator.ps1:10 char:2
+ [Windows.Markup.XamlReader]::Load($xamlReader)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : XamlParseException
You cannot call a method on a null-valued expression.
At H:\Powershell\Flow Rechner\Flow Calculator.ps1:13 char:1
+ $window.ShowDialog()
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
My XAML-File is an Basic one:
<Window x:Name="wpfWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="White"
Title="WPF Window"
mc:Ignorable="d">
<Grid>
<Grid Width="630"
Height="448"
Margin="0,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Grid.Column="0"
Grid.Row="0">
<Label x:Name="lb_Test"
Content="Test123"
Width="128"
Height="46"
Margin="41,55,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
RenderTransformOrigin="0.5154,0.5167"
Grid.Column="0"
Grid.Row="0" />
<Button x:Name="bt_Beenden"
Content="Beenden"
Width="75"
Height="23"
Margin="277.5,65.5,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Click="bt_beenden_click"
Grid.Column="0"
Grid.Row="0" />
</Grid>
</Grid>
</Window>
I’m using:
VSCode → 1.59.1
PowerShell Pro Tools → 5.28.1
Maybe this is an Issue on the Version of PowerShell Pro Tools