Forms & Class 
Author Message
 Forms & Class

I have created the following code using a ms sample
Imports System.Reflection
Public Class Form1
    Inherits System.Windows.Forms.Form
+windows form designer generated code
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
        Try
            Dim sLocation As String
            sLocation =
" http://www.*-*-*.com/ ;
            Dim FormAsm As [Assembly] = [Assembly].LoadFrom(sLocation)
            Dim Formtype As Type = FormAsm.GetType("novatest.form1")
            Dim Formobj As Object
            Formobj = Activator.CreateInstance(Formtype) <--------(crash
here)
            Dim Form1 As Form = CType(Formobj, Form)
            Form1.Show()
        Catch exc As Exception
            MsgBox("Error Message to follow")
            MsgBox(exc.ToString)
        End Try
    End Sub
End Class

The code crash's as marked, I do not understand what I am doing wrong  ?
Any help would be appreciated.

The dll it is trying to load establishes a connection to access and process
2 fields, nothing serious.

kind Regards



Sat, 26 Jun 2004 16:38:05 GMT  
 Forms & Class
On my side with the code below, the form1 was shown up as expected:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
        Try
            Dim sLocation As String
            sLocation = "E:\NET_Samples\ClassLibrary1\bin\ClassLibrary1.dll"
            Dim FormAsm As [Assembly] = [Assembly].LoadFrom(sLocation)
            Dim Formtype As Type = FormAsm.GetType("ClassLibrary1.Form1")
            Dim Formobj As Object
            Formobj = Activator.CreateInstance(Formtype)
            Dim Form1 As Form = CType(Formobj, Form)
            Form1.Show()
        Catch exc As Exception
            MsgBox("Error Message to follow")
            MsgBox(exc.ToString)
        End Try

    End Sub

The ClassLibrary1.dll is a VB.NET classlibrary containing a Public Windows
Form, Form1.vb.

The code above was tested on RC3.

This posting is provided ?AS IS?, with no warranties, and confers no
rights.



Tue, 29 Jun 2004 14:32:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Forms & Classes

2. Class & Forms

3. ActiveX EXE Classes & Forms Problem

4. Class Module & Form together

5. Class Mod Workaround & Multiple forms

6. Pass integer Value from forms Class mod to report class mod

7. Using Forms in Classes (beginner w/ classes needs help)

8. *&*&*&* Date math question *&*&*&*

9. Help in MSGBOX & FORMS &PROJECTS

10. Dim obj As New Class crt Dim Obj As Class = New Class

11. derive class from protected class in base class

12. MDI Forms & Child forms

 

 
Powered by phpBB® Forum Software