Scanning .NET Assemblies for References
Introduction As part of my work on running code in isolation , or sandbox, I set out to investigate how can we restrict what the hosted code runs, or, at least, find out what it is trying to do. I was interested in finding out what references does an assembly have, not just assembly references, but what types and methods it is actually accessing, from other assemblies. I ran into an old acquaintance, Mono.Cecil , which can helps us do just that, as I'll explain. Introducing Mono.Cecil From it's page on the Mono Project site: " Cecil is a library written by Jb Evain to generate and inspect programs and libraries in the ECMA CIL format. With Cecil, you can load existing managed assemblies, browse all the contained types, modify them on the fly and save back to the disk the modified assembly." Cecil is part of Mono Project , a most interesting initiative, which you should be aware of, if not already. It started in the old days of .NET Framework, when it wasn...