Hi. We run 2012 enterprise and unfortunately need to use reflection (long story) to call various methods from our c# scripts. I've shown a sample of that pattern below.
Someone asked me today if the results of reflection can be saved in such a way that sub pkgs can avoid using it over and over to reload the same assembly, properties etc? But instead reuse what was "saved" by doing it once perhaps in the mstr package?
System.Reflection.Assembly asmX = System.Reflection.Assembly.LoadFrom(Dts.Variables["asm Path"].Value.ToString()); Type y = asmX.GetType("a.b.c.d"); Type z = asmX.GetType("e"); var methodinfo = z.GetMethod("f", new Type[] { y, typeof(string) }); object anobj = Activator.CreateInstance(y); var connectionString = Dts.Variables["connstringvar"].Value.ToString(); y.GetProperty("some property").SetValue(anobj, "some string", null); methodinfo.Invoke(null, new object[] { anobj, connectionString });