VB.NET System.Reflection.TargetParameterCountException程序集加载

时间:2015-12-19 19:29:36

标签: .net vb.net methods .net-assembly invoke

当我尝试调用程序集(vb.net windows窗体应用程序)时,我收到错误“System.Reflection.TargetInvocationException”或“System.Reflection.TargetParameterCountException”。 “confusethis.exe”来源:

Public Class mainform
Private Sub mainform_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MsgBox("test")
End Sub
End Class

这是我调用的来源:

    Dim instance As FileStream = File.Open("confusethis.exe", FileMode.Open)
    Dim br As New BinaryReader(instance)
    Dim bin As Byte() = br.ReadBytes(Convert.ToInt32(instance.Length))
    instance.Close()
    br.Close()
    Dim a As Assembly = Assembly.Load(bin)
    Dim method As MethodInfo = a.EntryPoint
    If (IsDBNull(method) = False) Then
        Dim o As Object = a.CreateInstance(method.Name)
        method.Invoke(o, New Object() {New String() {"param1"}})
    Else
        MsgBox("error!")
    End If

我试过改变 method.Invoke(o, New Object() {New String() {"param1"}})method.Invoke(o, Nothing)method.Invoke(Nothing, Nothing)method.Invoke(o, New Object() {})

没有任何帮助,仍然有错误。

0 个答案:

没有答案