Skip to content

Instantly share code, notes, and snippets.

@Splaxi
Last active November 30, 2019 17:13
Show Gist options
  • Save Splaxi/0aa55b0fd96e466eea68eea82eeccc56 to your computer and use it in GitHub Desktop.
Save Splaxi/0aa55b0fd96e466eea68eea82eeccc56 to your computer and use it in GitHub Desktop.
.NET Reflection
[Reflection.Assembly]$ass = [Reflection.Assembly]::LoadFile("C:\Temp\File.dll")
$specificType = $ass.GetType("Namespace.Type")
$specificType.GetMethods([System.Reflection.BindingFlags]::NonPublic -bor [System.Reflection.BindingFlags]::Instance)
$instanceTypeObj = [System.Activator]::CreateInstance("Namespace.Type")
$nameOfMethod = $specificType.GetMethod("NameOfMethod", [System.Reflection.BindingFlags]::NonPublic -bor [System.Reflection.BindingFlags]::Instance)
$nameOfMethod.Invoke($instanceTypeObj, @(Parameter1, Parameter2, Parameter3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment