Reflection and Dynamic Assemblies

Print Friendly

Within one of my applications, I need to analyze loaded assemblies for a specific attribute. To do so I’ve write the following code :

foreach (System.Reflection.Assembly assembly in System.AppDomain.CurrentDomain.GetAssemblies()) {
	//Do something with the assembly
}

But I got System.NotSupportedException exception when I’ve execute that code. After a little serach through internet, I found the problem. It’s related with the dynamic assemblies that crated and loaded by a 3th party library used in my application. So first of all I shoul check for them :

if (assembly is System.Reflection.Emit.AssemblyBuilder) {
	continue;
}

This will allow you not to analyze dynamic assemblies.

No related posts.

Twitter Digg Delicious Stumbleupon Technorati Facebook Email

No comments yet... Be the first to leave a reply!

Leave a Reply

 
QR Code Business Card