Reflection utilizzo per istanziare dinamicamente delle dll

sabato 03 novembre 2012 - 21.20

massimo1965 Profilo | Junior Member

Ciao a Tutti,
sto giocando un po' con la reflection e vorrei una mano a capirci un po' di più...
Allora sono riuscito a creare un'istanza,eseguire una mia dll e a passargli pure dei parametri mediante InvokeMember
ma dovrebbe esserci anche un altro modo, utilizzando le info presenti nel type, ma non capisco come...
Chi mi da una mano ?
Grazie

Try Dim pAssemblyName As String = "...\WFDLL1.dll" Dim asmb As Assembly = Assembly.LoadFrom(pAssemblyName) For Each t As Type In asmb.GetTypes() If t.BaseType.Equals(GetType(Form)) Then If t.Name = "Form1" Then Dim frm As Form = Nothing frm = DirectCast(Activator.CreateInstance(t), Form) Dim oParam As Object() = New Object(0) {} oParam(0) = "Massimo" & DateTime.Now.ToLongTimeString t.InvokeMember("Nome", BindingFlags.SetProperty, Nothing, frm, oParam) frm.Show() End If End If Next Catch ex As Exception MessageBox.Show(ex.Message) End Try
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5