Scan Assemblies Using Reflection to Locate Performance Counter Installers


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. System.Reflection.Assembly assy = System.Reflection.Assembly.LoadFile(fileName);
  2. Type[] publicTypes = assy.GetExportedTypes();
  3. foreach (Type t in publicTypes)
  4. {
  5. if (t.BaseType.Name == "Installer")
  6. {
  7. MessageBox.Show(t.Name);
  8. Installer o = (Installer)t.Assembly.CreateInstance(t.FullName);
  9. foreach (Installer i in o.Installers)
  10. {
  11. if (i.GetType().Name == "PerformanceCounterInstaller")
  12. {
  13. MessageBox.Show("Performance Counter Installer Found in Assembly " + fileName);
  14. }
  15. }
  16. }
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.