UWP release build failded for need indicate of [DllImport(ExactSpelling=true)]

Volcano 56 Reputation points
2021-08-13T01:54:42.307+00:00

My cross-platform Xamarin.UWP solution is build on pure NuGet packages, without any DllImport. In debug module or release to android, everything is OK, except make a UWP release build.

This log indicate method 'api-ms-win-core-com-l1-1-0.dll!CreateBindCtx' and method 'api-ms-win-core-com-l1-1-0.dll!MkParseDisplayName' is the reason for failed:

83>
83>"D:\AppName.UWP\AppName.UWP.csproj" (_GenerateAppxPackage target) (1) ->
83>(BuildNativePackage target) -> 
83>  C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.10-rel-29722-00\tools\Microsoft.NetNative.targets(805,5): warning :       MCG : warning MCG0007: Unresolved P/Invoke method 'api-ms-win-core-com-l1-1-0.dll!CreateBindCtx' for method 'System.Void System.Runtime.InteropServices.ExternalInterop.CreateBindCtx(System.UInt32, System.Runtime.InteropServices.ComTypes.IBindCtx)'. 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 satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
83>  C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.10-rel-29722-00\tools\Microsoft.NetNative.targets(805,5): warning :       MCG : warning MCG0007: Unresolved P/Invoke method 'api-ms-win-core-com-l1-1-0.dll!MkParseDisplayName' for method 'System.Void System.Runtime.InteropServices.ExternalInterop.MkParseDisplayName(System.Runtime.InteropServices.ComTypes.IBindCtx, System.String, System.UInt32, System.Runtime.InteropServices.ComTypes.IMoniker)'. 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 satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
83>
83>
83>"D:\AppName.UWP\AppName.UWP.csproj" (_GenerateAppxPackage target) (1) ->
83>(BuildNativePackage target) -> 
83>  C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.10-rel-29722-00\tools\Microsoft.NetNative.targets(805,5): error : RHBIND : error RHB0002: Failed to write PDB.
83>  C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.10-rel-29722-00\tools\Microsoft.NetNative.targets(805,5): error : ILT0005: 'C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\runtime.win10-x86.microsoft.net.native.compiler\2.2.10-rel-29722-00\tools\x86\ilc\Tools\rhbind.exe @"D:\AppName.UWP\obj\x86\Release\ilc\intermediate\rhbindargs.AppName.UWP.rsp"' returned exit code 2
83>

But I have no idea which NuGut package need these indicate, and I don't know how to set the indicate.

Thanks for help!

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. Volcano 56 Reputation points
    2021-08-15T13:21:37.827+00:00

    I have removed all NuGet packages with placeholder except Xamarin.Essentials(Version="1.7.0") and Xamarin.Forms(Version="5.0.0.2083"), but the release build still failed. I think I have gone the wrong direction, maybe it's the failure of .NET Native Compiler.