locked
[UWP] ntdll.dll!RtlZeroMemory Error RRS feed

  • Question

  • Hello All,

    I'm trying to understand why I'm getting the following error.  Please note that I am not using DllImportAttribute with the RtZeroMemory function, yet I'm getting this error.  Also, the System.Void Interop.NtDll.ZeroMemory(System.IntPtr, System.UIntPtr) function does not show up anywhere in my application.  Lastly, double clicking the error does not bring me to any place in the code, but rather opens the Microsoft.NetNative.targets file (which I did not write or customize in any way).

    This error seems to be caused by the Microsoft.Net.Native.Compiler (v1.6.2), but I can't seem to fix it. 

    ERROR:
    8>C:\Users\rashadrivera\.nuget\packages\microsoft.net.native.compiler\1.6.2\tools\Microsoft.NetNative.targets(691,5): warning :       MCG : warning MCG0007: Unresolved P/Invoke method 'ntdll.dll!RtlZeroMemory' for method 'System.Void Interop.NtDll.ZeroMemory(System.IntPtr, System.UIntPtr)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisify those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.

    REF: C:\Users\rashadrivera\.nuget\packages\microsoft.net.native.compiler\1.6.2\tools\Microsoft.NetNative.targets


    - Rashad Rivera [omegusprime.com]

    Wednesday, July 26, 2017 6:41 PM

All replies

  • Hello All,

    I figured out that the System.Security.SecureString NuGet package from Microsoft is causing the warning.  Performing the following steps will reproduce this issue.

    1. Create an new C# UWP application
    2. Create a new C# .NET Standard class library
    3. Add the System.Security.SecureString package to the class library via the Manage NuGet Packages... option.
    4. Reference the class library in the UWP application
    5. In the MainPage constructor, put the following code:
      new ClassLibrary1.Class1();
    6. Change the build mode to RELEASE (the default is DEBUG)
    7. Compile the entire solution
      Note: you should not get *any* errors or warnings
    8. Add the following method to the ClassLibrary1.Class1 class
      public void DoWork() { new System.Security.SecureString(); }
    9. Recompile the application
      NOW YOU WILL GET THE ABOVE WARNING

    One correction, I'm getting a warning, not an error during compilation.  Obviously I expect to get an error when running the Windows App Cert Toolkit. 


    - Rashad Rivera [omegusprime.com]



    • Edited by Rashad Rivera Saturday, July 29, 2017 1:06 AM Added missing step
    Thursday, July 27, 2017 12:34 AM
  • Hello Rashad Rivera,

    I followed your above steps, but I can not get any error, and my app can work well using the Visual Studio 2017 and OS version 1703 and OS build is 15063.483. Could you check it again in a new project and help me to reproduce it?

    Best regards,

    Breeze


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 27, 2017 9:08 AM
  • Breeze,

    You are correct.  I forgot one step (see step 6 in the revised steps above).


    - Rashad Rivera [omegusprime.com]


    Saturday, July 29, 2017 1:02 AM
  • Hello Rashad Rivera,

    I tryed again to create a new project to test it in release mode following your above revised steps, but I can not get the warning or error. It can work well. Could you check your project reference to see the version of Microsoft.NETCore.UniversalWindowsPlatform nuget and the System.Security.SecureString package? I will try to test it on the same environment again in my visual studio 2017.

    Best regards,

    Breeze


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, August 1, 2017 8:13 AM
  • Liu,

    For some reason it is no longer causing the compilation issue.  I've tried the default NuGet version that comes when you add a new UWP app (v5.2.3) with System.Security.SecureString NuGet v4.3.0 before and experienced the error.  I tried it today and no errors.  Perhaps something changed in the last patch I got, but I'm not sure how to detect when I got a VS patch or the date it got applied.   

    Below is a screenshot of my VS installation to date.

    VS Version Info


    - Rashad Rivera [omegusprime.com]

    Thursday, August 10, 2017 4:24 AM