VB.NET Load and call DLL dynamically - the arithmetic operation caused an overflow

91 Views Asked by At

Hey guys following problem. I want to load a dll from embedded resources and inovke the entrypoint Sub Main(). But i get a exception when the desired Sub Main() from dll is triggerd. Sorry for my english. I hope you can explain the error and give me a solution.

Here is the DLL i want to load Sub Main():

Namespace MyApp

Public Class EntryPoint
    Public Shared Sub Main()
        Dim FrmMain As New Form1
        System.Windows.Forms.Application.Run(FrmMain)
    End Sub
End Class 

Yeah it is correct that the dll loads a form on main()

And that is how i call it:

        Dim bytes As Byte() = Convert.FromBase64String(My.Resources.src2)
        Dim oType As System.Type
        Dim oAssembly As System.Reflection.Assembly
        Dim oObject As System.Object
        oAssembly = Assembly.Load(bytes)
        oType = oAssembly.GetType("MyApp.EntryPoint")
        oObject = Activator.CreateInstance(oType)
        oObject.Main()

The error that appears after 5 sec from loading sub main() is : "the arithmetic operation caused an overflow"

Please help me i am learning. Thank you very much.

0

There are 0 best solutions below