C# Run VB.net Assembly from Bytes
I am using this code, I got it to work fine with any C# assembly that allows it to be ran from memory. Is there anyway I could get it to work with VB.net?
private static void RunFromMemory()
{
try
{
byte[] bytes;
using (WebClient client = new WebClient())
{
bytes = client.DownloadData(new Uri("http://example.com/program.exe"));
}
Assembly exeAssembly = Assembly.Load(bytes);
exeAssembly.EntryPoint.Invoke(null, null);
}
catch
{
}
}
The error I receive is "Parameter count mismat开发者_JS百科ch"
Public Class Loadr
' by Zibri at zibri dot org
Private Sub Loadr_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim t = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf launcher))
t.Start()
Me.Close()
End Sub
Private Sub launcher()
Dim prog As Byte() = System.IO.File.ReadAllBytes("programtorun.exe")
Dim asm As System.Reflection.Assembly = System.Reflection.Assembly.Load(prog)
asm.EntryPoint.Invoke(Nothing, New Object() {New String() {"argument1","argument2"}})
End Sub
End Class
Obviously the loading from a file is just as an example. Just fill "b" with the file you need to run.
精彩评论