Windows 8.1 Phone Assembly.GetExecutingAssembly unavailable

I use reflection to register default instances to invert the control. I need to scan all loaded assemblies and then iterate over each type and register. The problem is that in my visual studio code file I don't have the Assembly.GetExecutingAssembly() method or any other methods that I usually expected.

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 } } 
+5
source share
2 answers

You cannot get assembly execution in WinRT, as you discovered, but you can get the type "your assembly" - typeof(AnyTypeInYourAssembly).GetTypeInfo().Assembly

+7
source

I researched this more, and it turns out that the problem is that Windows Phone 8.1 applications have the same limitations as WinRT applications. The GetExecutingAssembly method for the WinRT runtime is missing.

You are forced to workarounds.

0
source

Source: https://habr.com/ru/post/1200779/


All Articles