vb2008 doesn't call a sub in a form Called through assembly
-
Dear All: I have a problem in vb2008 that when using assembly method to call a form ,When trying to call a sub within this form vb2008 doesn't do anything. could you help me Thanks in advance Aiman Farouk
-
Dear All: I have a problem in vb2008 that when using assembly method to call a form ,When trying to call a sub within this form vb2008 doesn't do anything. could you help me Thanks in advance Aiman Farouk
just two days back only i solved this problem, Try this below code and this may help you to find out your solution
******This is your windows application or class library project, but it should be "Public Module"******
Public Module TestModule
Public Sub Test()
MsgBox("Test successfully completed")
End Sub
End Module******Below Code to your Current Project******
Imports System.Reflection******Use the below code at any event or funtions******
Dim Path As String = "......\"
Dim FileName As String = "XXXX.dll" 'Or "XXXX.exe"
Dim FileAssembly As Assembly = Reflection.Assembly.LoadFile(Path & FileName)
Dim ModuleName As String = "TestModule"
Dim SubName As String = "Test"
Dim RefType As Type = FileAssembly.GetType(FileAssembly.GetName.Name & "." & ModuleName)
Dim MyForm As Form = New Form
RefType.InvokeMember(SubName, BindingFlags.InvokeMethod, Nothing, MyForm, Nothing)Please tell me the above codes are working or not.......
-
just two days back only i solved this problem, Try this below code and this may help you to find out your solution
******This is your windows application or class library project, but it should be "Public Module"******
Public Module TestModule
Public Sub Test()
MsgBox("Test successfully completed")
End Sub
End Module******Below Code to your Current Project******
Imports System.Reflection******Use the below code at any event or funtions******
Dim Path As String = "......\"
Dim FileName As String = "XXXX.dll" 'Or "XXXX.exe"
Dim FileAssembly As Assembly = Reflection.Assembly.LoadFile(Path & FileName)
Dim ModuleName As String = "TestModule"
Dim SubName As String = "Test"
Dim RefType As Type = FileAssembly.GetType(FileAssembly.GetName.Name & "." & ModuleName)
Dim MyForm As Form = New Form
RefType.InvokeMember(SubName, BindingFlags.InvokeMethod, Nothing, MyForm, Nothing)Please tell me the above codes are working or not.......
Thank you for your reply . I tried it but an error displayed System.Reflection.TargetInvocationException was unhandled again I want to clear it I want to call a public sub declared inside the form class which I am opening through assembly Hope to clear it for me