2017-08-25 65 views
-3

我正在使用Powershell来操作WPF数据网格。 我想添加一个DataGridComboBoxColumn,我必须加载这个程序集 [System.Reflection.Assembly] :: LoadWithPartialName(“System.windows.controls”)|外空Powershell [System.Reflection.Assembly] :: LoadWithPartialName(“System.Windows.controls”)未加载

但是,它不断给我一个错误

我不知道如果我加载该组件的错误的方式。 可以请你协助吗?

谢谢

+0

你得到的错误是什么? – ArcSet

回答

0

它看起来像你试图加载时,你应该改为尝试加载包含命名空间中的组件的命名空间。

System.Windows.Controls是内PresentationFramewkork.dll

命名空间你能尝试加载PresentationFramework呢?

PS> [System.Reflection.Assembly]::LoadWithPartialName("PresentationFramework") 

GAC Version  Location 
--- -------  -------- 
True v4.0.30319  C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.... 

PS> $object = [System.Windows.Controls.Control] 

PS> $object.GetMembers() 

Name      : get_BorderBrush 
DeclaringType    : System.Windows.Controls.Control 
ReflectedType    : System.Windows.Controls.Control 
MemberType     : Method 
MetadataToken    : 100680700 
Module      : PresentationFramework.dll 
... 
0

井已经装好。

尝试运行此操作。

$ExportedTypes = [appdomain]::CurrentDomain.GetAssemblies() | select ExportedTypes 
Foreach($ExportedType in $ExportedTypes){ 
    $ExportedType.ExportedTypes | ?{$_.FullName -like "system.windows.controls*"} | select FullName, Module 
} 

如果您得到任何结果,它已被加载。

你正在加载的程序集实际上就是PresentationFramework.dll的一部分