Here is what I have but it isn't working if someone could point me in
the right direction I would greatly appreciate it.
Try
Dim objAssembly As Reflection.Assembly
ds.Tables("Main_Menu").DefaultView.RowFilter = "Menu_Name =
'" & sender.text & "'"
objAssembly =
objAssembly.LoadFrom(ds.Tables("Main_Menu").Defaul tView.Item(0).Item("Assembly"))
Dim typClsX As Type =
objAssembly.GetType(ds.Tables("Main_Menu").Default View.Item(0).Item("Assembly_Type"),
True, True)
objAssembly.GetReferencedAssemblies()
objAssembly.GetCustomAttributes(True)
objAssembly.GetEntryAssembly()
Dim cons() As ConstructorInfo
cons = typClsX.GetConstructors(BindingFlags.CreateInstanc e
Or BindingFlags.Instance Or BindingFlags.InvokeMethod Or
BindingFlags.Public Or BindingFlags.NonPublic Or
BindingFlags.DeclaredOnly)
Dim Params() As ParameterInfo = cons(0).GetParameters()
Dim MyString() As String = {"Test", "Tester"}
Dim Frm As New Form
Frm = Activator.CreateInstance(typClsX.BaseType,
BindingFlags.CreateInstance Or BindingFlags.Instance Or
BindingFlags.Public Or BindingFlags.DeclaredOnly)
cons.Initialize()
<b>Here is where I recieve the error</b>
Activator.CreateInstance(cons(0).Invoke(BindingFla gs.CreateInstance Or
BindingFlags.DeclaredOnly Or BindingFlags.Instance Or
BindingFlags.Public, Nothing, CType(New Object() {New String()
{"TEST"}, New String() {"Tester"}}, Object), Nothing))
Catch ex As Exception
MessageBox.Show(ex.ToString & " " & ex.Message & " " &
Err.Source & " " & Err.Description)
End Try
End Sub
End Class
<b>This is what I am trying to open. I am using general code right now
and will apply it to what I need after I figure it out.</b>
ublic Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub SetValues(ByRef label1 As String, ByRef label2 As
String)
Me.Label2.Text = label1
Me.Label3.Text = label2
End Sub
Friend Sub New(ByVal label1 As String, ByVal label2 As String)
MyBase.New()
Me.Label2.Text = Label1
Me.Label3.Text = Label2
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()Private Sub
InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(0, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(640, 520)
Me.Label1.TabIndex = 0
Me.Label1.Text = "This is a test...."
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 32)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(224, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Label2"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 88)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(320, 24)
Me.Label3.TabIndex = 2
Me.Label3.Text = "Label3"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(640, 518)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click
End Sub
End Class 2 1395
Rjjaw,
Using reflection is seldom the right route to the good solution. Can you
tell us what you want to achieve, just a bunch of code does not add much to
our own knowledge. And because that this newsgroup is to learn for everybody
from somebody else (How stupid it sometimes is), it needs to have sense.
Cor
"rjjaw" <jo********@heritagefunds.comschreef in bericht
news:11*********************@n67g2000cwd.googlegro ups.com...
Here is what I have but it isn't working if someone could point me in
the right direction I would greatly appreciate it.
Try
Dim objAssembly As Reflection.Assembly
ds.Tables("Main_Menu").DefaultView.RowFilter = "Menu_Name =
'" & sender.text & "'"
objAssembly =
objAssembly.LoadFrom(ds.Tables("Main_Menu").Defaul tView.Item(0).Item("Assembly"))
Dim typClsX As Type =
objAssembly.GetType(ds.Tables("Main_Menu").Default View.Item(0).Item("Assembly_Type"),
True, True)
objAssembly.GetReferencedAssemblies()
objAssembly.GetCustomAttributes(True)
objAssembly.GetEntryAssembly()
Dim cons() As ConstructorInfo
cons = typClsX.GetConstructors(BindingFlags.CreateInstanc e
Or BindingFlags.Instance Or BindingFlags.InvokeMethod Or
BindingFlags.Public Or BindingFlags.NonPublic Or
BindingFlags.DeclaredOnly)
Dim Params() As ParameterInfo = cons(0).GetParameters()
Dim MyString() As String = {"Test", "Tester"}
Dim Frm As New Form
Frm = Activator.CreateInstance(typClsX.BaseType,
BindingFlags.CreateInstance Or BindingFlags.Instance Or
BindingFlags.Public Or BindingFlags.DeclaredOnly)
cons.Initialize()
<b>Here is where I recieve the error</b>
Activator.CreateInstance(cons(0).Invoke(BindingFla gs.CreateInstance Or
BindingFlags.DeclaredOnly Or BindingFlags.Instance Or
BindingFlags.Public, Nothing, CType(New Object() {New String()
{"TEST"}, New String() {"Tester"}}, Object), Nothing))
Catch ex As Exception
MessageBox.Show(ex.ToString & " " & ex.Message & " " &
Err.Source & " " & Err.Description)
End Try
End Sub
End Class
<b>This is what I am trying to open. I am using general code right now
and will apply it to what I need after I figure it out.</b>
ublic Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub SetValues(ByRef label1 As String, ByRef label2 As
String)
Me.Label2.Text = label1
Me.Label3.Text = label2
End Sub
Friend Sub New(ByVal label1 As String, ByVal label2 As String)
MyBase.New()
Me.Label2.Text = Label1
Me.Label3.Text = Label2
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()Private Sub
InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(0, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(640, 520)
Me.Label1.TabIndex = 0
Me.Label1.Text = "This is a test...."
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 32)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(224, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Label2"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 88)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(320, 24)
Me.Label3.TabIndex = 2
Me.Label3.Text = "Label3"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(640, 518)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click
End Sub
End Class
The application I developed opens slowly because it has to load a lot
of forms that may not be used. What I am attempting to do, and my
overall goal for the complete project is to only load what I need when
it is request such as the forms. I would like to make a dashboard that
each of my departments would use and only load their applications they
need at runtime as well.
Cor Ligthert [MVP] wrote:
Rjjaw,
Using reflection is seldom the right route to the good solution. Can you
tell us what you want to achieve, just a bunch of code does not add much to
our own knowledge. And because that this newsgroup is to learn for everybody
from somebody else (How stupid it sometimes is), it needs to have sense.
Cor
"rjjaw" <jo********@heritagefunds.comschreef in bericht
news:11*********************@n67g2000cwd.googlegro ups.com...
Here is what I have but it isn't working if someone could point me in
the right direction I would greatly appreciate it.
Try
Dim objAssembly As Reflection.Assembly
ds.Tables("Main_Menu").DefaultView.RowFilter = "Menu_Name =
'" & sender.text & "'"
objAssembly =
objAssembly.LoadFrom(ds.Tables("Main_Menu").Defaul tView.Item(0).Item("Assembly"))
Dim typClsX As Type =
objAssembly.GetType(ds.Tables("Main_Menu").Default View.Item(0).Item("Assembly_Type"),
True, True)
objAssembly.GetReferencedAssemblies()
objAssembly.GetCustomAttributes(True)
objAssembly.GetEntryAssembly()
Dim cons() As ConstructorInfo
cons = typClsX.GetConstructors(BindingFlags.CreateInstanc e
Or BindingFlags.Instance Or BindingFlags.InvokeMethod Or
BindingFlags.Public Or BindingFlags.NonPublic Or
BindingFlags.DeclaredOnly)
Dim Params() As ParameterInfo = cons(0).GetParameters()
Dim MyString() As String = {"Test", "Tester"}
Dim Frm As New Form
Frm = Activator.CreateInstance(typClsX.BaseType,
BindingFlags.CreateInstance Or BindingFlags.Instance Or
BindingFlags.Public Or BindingFlags.DeclaredOnly)
cons.Initialize()
<b>Here is where I recieve the error</b>
Activator.CreateInstance(cons(0).Invoke(BindingFla gs.CreateInstance Or
BindingFlags.DeclaredOnly Or BindingFlags.Instance Or
BindingFlags.Public, Nothing, CType(New Object() {New String()
{"TEST"}, New String() {"Tester"}}, Object), Nothing))
Catch ex As Exception
MessageBox.Show(ex.ToString & " " & ex.Message & " " &
Err.Source & " " & Err.Description)
End Try
End Sub
End Class
<b>This is what I am trying to open. I am using general code right now
and will apply it to what I need after I figure it out.</b>
ublic Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub SetValues(ByRef label1 As String, ByRef label2 As
String)
Me.Label2.Text = label1
Me.Label3.Text = label2
End Sub
Friend Sub New(ByVal label1 As String, ByVal label2 As String)
MyBase.New()
Me.Label2.Text = Label1
Me.Label3.Text = Label2
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()Private Sub
InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(0, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(640, 520)
Me.Label1.TabIndex = 0
Me.Label1.Text = "This is a test...."
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 32)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(224, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Label2"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 88)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(320, 24)
Me.Label3.TabIndex = 2
Me.Label3.Text = "Label3"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(640, 518)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click
End Sub
End Class
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Benjamin |
last post by:
Hi,
I'm currently writing a Web Services that interacts with a database.
To allow me to use not just one database provider (for example, I
could use MS Access, SQL Server or MySQL), the Web...
|
by: Kyle M. Burns |
last post by:
I have an application where I needed to refactor to a base class using the
template method pattern in order to avoid duplication of code between two
objects that needed to fulfill the same...
|
by: Andrew Backer |
last post by:
Hello,
I am having a problem creating a class dynamically. The class I have
is a base class of another, and the parent class has the constructor
(which takes one argument). The base class...
|
by: Mark Raishbrook |
last post by:
A client of mine is getting a NullReferenceException when starting up a small
app I've written. I've traced the cause to an unregistered DLL the app
references, so the error itself is not the...
|
by: Ron M. Newman |
last post by:
Hi,
I have a custom string collection editor for my property grid.
when I set the property.customEditor, I found to my amazement that you can't instantiate a new object from an assembly that's...
| |
by: forest demon |
last post by:
for example, let's say I do something like,
System.Diagnostics.Process.Start("notepad.exe","sample.txt");
if the user does a SaveAs (in notepad), how can i capture the path that
the user...
|
by: Smithers |
last post by:
Using 3.5, I am stuck in attempting to:
1. Dynamically load an assembly
2. Instantiate a class from that assembly (the client code is in a different
namespace than the namespace of the...
|
by: Jeff |
last post by:
Hi
I'm trying to achieve a scenario where I have c# files that are compiled
dynamically, the assemblies are then loaded in a different AppDomain, I call
a simple method from the object, and then...
|
by: puzzlecracker |
last post by:
is there a way to create a library (assembly/dll) where I can only
export few class? I don't want client to use or know about other
internal classes in the assembly.
Thanks
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |