使用反射,我如何获得在.NET Core中实现某些特定接口的所有类型?我注意到.NET 4.6中可用的方法不再可用.
例如,此代码不起作用.
var type = typeof(IMyInterface);
var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => type.IsAssignableFrom(p));
Run Code Online (Sandbox Code Playgroud)
它抛出The name 'AppDomain' does not exist in the current context错误.