I am using reflection to register default instances for inversion of control. I need to scan all loaded assemblies and then iterate through each type and register. The problem is that in my visual studio code file I do not have the method Assembly.GetExecutingAssembly()
or any other methods that I would normally expect.
Why is this happening. My code should look like this:
foreach (var type in (Assembly.GetExecutingAssembly().GetTypes())
{
if (type.IsClass && !type.IsAbstract)
{
//registers the type for an interface it implements
}
}
You can't get executing assembly in WinRT as you have discovered - but you can get type in "your assembly" - typeof(AnyTypeInYourAssembly).GetTypeInfo().Assembly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With