Search code examples
windows-runtimeuwp.net-native

GetCustomAttributes method (System.Reflection.Module) returns nothing if Application compiled with .NET Native


I have UWP code which is working with System.Reflection.Module type. When the app is compiled in DEBUG mode all is ok and I can get custom attributes for the module. But when I switch to RELEASE mode and compile the app with .NET Native all those attributes disappear.


Solution

  • After your application is run through the .Net Native tool chain (ilc.exe) you'll notice that your application binaries don't appear as you'd naively expect. This is because all of your .Net code (including the piece of the .Net Framework your app requires) has been folded into a single binary .dll. We do this because many optimization steps work much better when the compiler can view the entire state of your program. It also can speed up your start time because finding a bunch of different files on disk isn't on the hot path.

    Given all of the above, it was necessary to come up with a policy for Assembly attributes. In the end, it was easier to eliminate support than to figure out a way to get conflicting things to mesh nicely.

    If you have a scenario that is only possible through these attributes we'd love to know more about it.