Ivan Glasenberg
Ivan Glasenberg

Reputation: 29985

How to get the information like classes inside a dll file?

I have a .net framework dll file, and it has some classes.

I want to use powershell to get all the classes' name inside the .dll file, how can I do?

update:

when I tried using import-module "xxxxx", it has the following error.

enter image description here

Upvotes: 0

Views: 1267

Answers (2)

vonPryz
vonPryz

Reputation: 24071

Another a way: import the DLL with Import-Module and call assembly's GetTypes(). Like so,

import-module '<your_path>\Microsoft.SqlServer.Smo.dll'
$smo = ([appdomain]::CurrentDomain.GetAssemblies()) | 
    where {$_.modules.name.contains('SqlServer')}
$smo.gettypes() | where {$_.isPublic -and $_.isClass}

Upvotes: 2

TessellatingHeckler
TessellatingHeckler

Reputation: 29003

I think you can do:

$Assembly = [System.Reflection.Assembly]::LoadFrom('c:\temp\file.dll')
$Assembly.DefinedTypes
$Assembly.GetExportedTypes()
$Assembly.GetLoadedModules()

Upvotes: 4

Related Questions