以下代码在ise中,或是复制到powershell中,皆可正常执行:
Add-Type -AssemblyName PresentationCore,PresentationFramework,WindowsBase,System.Xaml;
class mywin : System.Windows.Window{};
[mywin]::new().ShowDialog() |Out-Null;
但是保存成ps1后,无论是右键使用powershell运行,还是在powershell中执行该ps1,都报错:
找不到类型 [System.Windows.Window]。
请问是什么原因