Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows phone 8.1 Assembly.GetExecutingAssembly not available

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
    }
}
like image 703
Alecu Avatar asked Aug 20 '14 18:08

Alecu


1 Answers

You can't get executing assembly in WinRT as you have discovered - but you can get type in "your assembly" - typeof(AnyTypeInYourAssembly).GetTypeInfo().Assembly

like image 139
fex Avatar answered Oct 17 '22 04:10

fex