For example...
using System;
using System.IO;
namespace Whatever
{
public class SomeClass
{
}
}
If this is compiled into class library mylibrary.dll, I want to be able to use reflection to load mylibrary.dll and find out if it is referencing the System.IO
namespace.
I've tried using Assembly.GetReferencedAssemblies
and then identifying namespaces in those assemblies, but this will always give me all of the namespaces defined in those assemblies whether or not they're actually referenced in mylibrary.dll. Since System.IO
shares an assembly with System
and many other important namespaces, this won't work.
Another thing I've thought of is to find out if a class from that namespace is referenced, but I can't find a way to do that using reflection.
This is for a plugin system, and the idea is to prevent the plugin from using certain namespaces, such as System.IO
, by refusing to load the library if those namespaces are referenced.