我有一个.net framework dll文件,它有一些类。我想用powershell来获取.dll文件中所有类的名称,我该怎么做?更新:当我尝试使用import-module "xxxxx"时,它有以下错误。
import-module "xxxxx"
c8ib6hqw1#
我认为你可以做到:
$Assembly = [System.Reflection.Assembly]::LoadFrom('c:\temp\file.dll') $Assembly.DefinedTypes $Assembly.GetExportedTypes() $Assembly.GetLoadedModules()
nbysray52#
另一种方法:使用Import-Module导入DLL并调用程序集的GetTypes()。像这样
Import-Module
GetTypes()
import-module '<your_path>\Microsoft.SqlServer.Smo.dll' $smo = ([appdomain]::CurrentDomain.GetAssemblies()) | where {$_.modules.name.contains('SqlServer')} $smo.gettypes() | where {$_.isPublic -and $_.isClass}
2条答案
按热度按时间c8ib6hqw1#
我认为你可以做到:
nbysray52#
另一种方法:使用
Import-Module
导入DLL并调用程序集的GetTypes()
。像这样