Wednesday, May 12, 2021

How to load and execute DLL from Powershell.


Compile using Visual Studio Community following code:


Imports System

Public Module HelloWorld

Sub main()
Console.WriteLine("Hello World Using Visual Basic Code!")
'Msgbox("Hello World from My DotNET Assembly !")
    End Sub
End Module



Execution in Powershell:


$filename = "C:\Users\jarekole\source\repos\ConsoleApp1\ConsoleApp1\bin\Debug\netcoreapp3.1\ConsoleApp1.dll"
$assembly = [Reflection.Assembly]::Loadfile($filename)

$assembly.gettype()

$assembly.fullName
$assembly.gettypes()
$assembly.GetName() |select * | fl
$assembly.GetTypes() | select UnderlyingSystemType 
[ConsoleApp1.HelloWorld]::main()


No comments:

Post a Comment