Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

using reflection only once on assembly that will be invoked repeatedly by sub packages

$
0
0

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 });

 


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>