System.Collections.Generic完全限定名称

时间:2014-02-13 03:19:03

标签: powershell

存储System.Collections.Generic的程序集的完全限定名称是什么?

我有这段代码:

Add-Type -AssemblyName "System.XML.Linq"
Add-Type -AssemblyName "System.Collections.Generic"

Linq得到了很好的补充,但是我收到了System.Collections.Generic的错误:

Add-Type : Cannot add type. The assembly 'System.Collections.Generic' could not be found.

How do I use Add-Type to load Microsoft.Web.Deployment?表示要使用完全限定名称,例如:

Add-Type -AssemblyName ('Microsoft.Web.Deployment, Version=7.1.0.0, ' +
                        'Culture=neutral, PublicKeyToken=31bf3856ad364e35')

如何找出完全限定名称?

1 个答案:

答案 0 :(得分:2)

命名空间System.Collections.Generic中的类型主要位于mscorlib.dll中,并自动加载到PowerShell中。您不需要Add-Type来使用大多数通用集合。您应该检查要使用的特定集合类型以确保。 Dictionary由mscorlib.dll提供。

要查找完全限定名称,请使用MSDN文档查找包含该类型的程序集。然后在PowerShell中的C:\ windows \ assembly \ GAC_MSIL下查看。按名称查找程序集,子目录将列出版本和pubkey标记。