Search code examples
c#c++windows-phone-8.1ngen

How to disable Native Image Generation on Windows Phone 8.1?


I've got a c++ application for Windows Phone 8.1, which uses a C# module for xml processing. The NGEN'd version of that module throws and InvalidCastException from System.StubHelpers.InterfaceMarshaler.ConvertToNative, but the non-NGEN'd version works fine (more details here: http://social.msdn.microsoft.com/Forums/en-US/16fa4316-d0ae-4aca-ac70-9946c6cc4dfb/ngend-dll-throws-exception-but-winmd-does-not?forum=wpdevelop).

Anyway, as a workaround until I resolve the underlying issue, I would like to simply disable native image generation for my app. However, the approach suggested on msdn of including a nongen.txt file in the root of the appx does not seem to be working... the file is there, but the C# module still seems to be getting NGEN'd. Has anyone else run into this / does anyone know how to disable NGEN for an app on Windows Phone 8.1?


Solution

  • I managed to get ahold of a guy from .NET Native who is familiar with the native image generation process. Apparently there currently is no way to disable native image generation on Windows Phone. Here's the full response:

    "Nongen.txt is not supported on Windows Phone. Technically, NGen doesn’t really exist on phone. Native code generation on phone goes through a very different set of steps compared to Windows. There is currently no supported mechanism for skipping native code generation when the app is deployed through Phone app store."

    Too bad - that would have been a handy workaround.