Torna al Thread

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { object obj; Type type; //mi carico l'assembly Assembly ass = Assembly.LoadFrom("C:\\Documents and Settings\\riccardo\\Documenti\\Visual Studio 2008\\Projects\\TestLibrary\\TestLibrary\\bin\\Debug\\TestLibrary.dll"); //carico i tipi (in questo caso solo 1: prova_adll_reflection.ProvaReflection) type = ass.GetTypes()[0]; //Creo un'istanza del tipo obj = Activator.CreateInstance(type); //Invoco un metodo di nome MsgBox. //Se non conoscessi i metodi dovrei prima caricarmeli in un array //ma per semplicità non lo faccio string argst = "ciao come va?"; object[] arg = new object[1]; arg[0] = (Object) argst; object test = type.InvokeMember("method1", BindingFlags.Default | BindingFlags.InvokeMethod, null, obj, arg); Console.WriteLine(test.ToString()); } } }
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5