question

evolcano avatar image
0 Votes"
evolcano asked NicoZhu-MSFT commented

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

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!

windows-uwp
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

derive from ILT0005 code, it looks you referred package does not support release model, could you mind share which package you have used?

0 Votes 0 ·

These packages:

  1. SixLabors.ImageSharp" Version="1.0.3"

  2. ZXing.Net.Mobile" Version="3.1.0-beta2"

  3. Newtonsoft.Json" Version="13.0.1"

  4. Microsoft.Data.Sqlite" Version="5.0.8"

  5. EPPlus" Version="5.7.2"

  6. Plugin.HybridWebView" Version="1.0.0.2-alpha"

  7. Plugin.NFC" Version="0.1.20"

  8. SixLabors.ImageSharp" Version="1.0.3"

  9. SkiaSharp" Version="2.80.3"

  10. SkiaSharp.Views.Forms" Version="2.80.3"

  11. Xamarin.Controls.SignaturePad.Forms" Version="3.0.0"

  12. Xamarin.Essentials" Version="1.7.0"

  13. Xamarin.FFImageLoading.Svg.Forms" Version="2.4.11.982"

  14. Xamarin.Forms" Version="5.0.0.2083"

  15. Plugin.MediaManager.Forms" Version="1.0.9"

  16. Plugin.AudioRecorder" Version="1.1.0"

  17. Xam.Plugin.Media" Version="5.0.1"

  18. ZXing.Net.Mobile.Forms" Version="3.1.0-beta2"

Thanks!

0 Votes 0 ·

Have you tried remove Microsoft.Data.Sqlite package and rebuild the project?

0 Votes 0 ·
Show more comments

1 Answer

evolcano avatar image
0 Votes"
evolcano answered NicoZhu-MSFT commented

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.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

It throw the same error in all the machine, have you tried build in other machine?

0 Votes 0 ·