4

So I've got a simple app that works on the Android emulator and physical Opel phone, but when I deploy to iPhone I getting a bunch of errors. For starters...

Could not resolve assembly Microsoft.VisualStudio.DesignTools.TapContract

Surely a tap gesture should work out of the box?

Here's the full list:

2022-08-22 23:14:34.473 Xamarin.PreBuilt.iOS[94921:6409975] Could not resolve assembly Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/6B3B6CF6-2A5A-452F-956D-74D8A66941EA/Documents/Lofty.Logbook.content/Microsoft.VisualStudio.DesignTools.TapContract.dll' or one of its dependencies.

2022-08-22 23:14:34.475 Xamarin.PreBuilt.iOS[94921:6409975] Could not resolve assembly Xamarin.HotReload.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/6B3B6CF6-2A5A-452F-956D-74D8A66941EA/Documents/Lofty.Logbook.content/Xamarin.HotReload.Contracts.dll' or one of its dependencies.

Resolved pending breakpoint for 'Xamarin.HotReload.HotReloadAgent.BreakpointSendToIde(System.String)' to D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Agent\HotReloadAgent.cs:419 [0x00000].
2022-08-22 23:14:34.617 Xamarin.PreBuilt.iOS[94921:6409975] Could not resolve assembly Xamarin.HotReload.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/6B3B6CF6-2A5A-452F-956D-74D8A66941EA/Documents/Lofty.Logbook.content/Xamarin.HotReload.Contracts.dll' or one of its dependencies.

2022-08-22 23:14:34.618 Xamarin.PreBuilt.iOS[94921:6409975] Could not resolve assembly Microsoft.VisualStudio.DesignTools.TapContract, Version=17.0.0.0, Culture=neutral, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/6B3B6CF6-2A5A-452F-956D-74D8A66941EA/Documents/Lofty.Logbook.content/Microsoft.VisualStudio.DesignTools.TapContract.dll' or one of its dependencies.

Resolved pending breakpoint for 'Xamarin.HotReload.HotReloadAgent.BreakpointCheckpoint()' to D:\a\_work\1\s\HotReload\Source\Xamarin.HotReload.Agent\HotReloadAgent.cs:414 [0x00000].
Resolved pending breakpoint at 'MauiProgram.cs:40,1' to Lofty.Logbook.Database.EntityDbContext Lofty.Logbook.MauiProgram.<>c__DisplayClass0_0.<CreateMauiApp>b__1 (System.IServiceProvider x) [0x00058].
Resolved pending breakpoint at 'MauiProgram.cs:32,1' to Lofty.Logbook.Database.EntityDbContext Lofty.Logbook.MauiProgram.<>c__DisplayClass0_0.<CreateMauiApp>b__1 (System.IServiceProvider x) [0x00023].
Thread started:  #7
Thread started:  #8
Thread started:  #9
2022-08-22 23:14:35.102 Xamarin.PreBuilt.iOS[94921:6409975] Could not resolve assembly System.Private.DataContractSerialization.resources, Version=6.0.0.0, Culture=en-AU, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/6B3B6CF6-2A5A-452F-956D-74D8A66941EA/Documents/Lofty.Logbook.content/System.Private.DataContractSerialization.resources.dll' or one of its dependencies.

2022-08-22 23:14:35.103 Xamarin.PreBuilt.iOS[94921:6409975] Could not resolve assembly System.Private.DataContractSerialization.resources, Version=6.0.0.0, Culture=en, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/6B3B6CF6-2A5A-452F-956D-74D8A66941EA/Documents/Lofty.Logbook.content/System.Private.DataContractSerialization.resources.dll' or one of its dependencies.

2022-08-22 23:14:35.247 Xamarin.PreBuilt.iOS[94921:6409975] Could not resolve assembly Microsoft.EntityFrameworkCore.resources, Version=6.0.8.0, Culture=en-AU, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/6B3B6CF6-2A5A-452F-956D-74D8A66941EA/Documents/Lofty.Logbook.content/Microsoft.EntityFrameworkCore.resources.dll' or one of its dependencies.

2022-08-22 23:14:35.248 Xamarin.PreBuilt.iOS[94921:6409975] Could not resolve assembly Microsoft.EntityFrameworkCore.resources, Version=6.0.8.0, Culture=en, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/6B3B6CF6-2A5A-452F-956D-74D8A66941EA/Documents/Lofty.Logbook.content/Microsoft.EntityFrameworkCore.resources.dll' or one of its dependencies.

    [0:] An error occurred: 'e_sqlite3'. Callstack: '   at SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_libversion_number()
       at SQLitePCL.raw.SetProvider(ISQLite3Provider imp)
       at SQLitePCL.Batteries_V2.Init()
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)'
    The app has been terminated.

Anyone know how to resolve this? I'm guessing sqlite pcl is the main issue

Update: Here's a demo project that illustrates the issue I'm facing. https://github.com/steveski/MauiEFIssue

Stephen York
  • 1,247
  • 1
  • 13
  • 42
  • Have you created the `Entitlements.plist` file and pasted it under Platforms/iOS folder in your MAUI project? If not, see my answer. – Alexandar May - MSFT Aug 23 '22 at 02:36
  • I see those "could not resolve assembly" errors all the time and they don't impact my app. The Entitlements.plist is not a requirement to successful execution. The exception seems to imply an issues with SQLite. Have you tried to pinpoint which line of EF code causes the issue? – Tomas McGuinness Aug 26 '22 at 20:33
  • Has nothing to do with SQL Lite. I'm getting the same error and not touching anything related to SQL. Didn't start seeing these errors until started including the MSAL libraries. – Quark Soup Aug 28 '22 at 21:41
  • @TomasMcGuinness After the creation of the EntityDbContext is where it dies, somewhere in the lifecycle hooks of the base DbContext. It never gets past the new EntityDbContext call – Stephen York Aug 29 '22 at 02:54
  • I dont know why, but removing all breakpoints solve my problem – Fitri Halim Mar 27 '23 at 14:54

1 Answers1

1

You need add a new entitlements file to your .NET Multi-platform App UI (.NET MAUI) app project, and add a new XML file named Entitlements.plist to the Platforms\iOS\ folder of your app project. Then add the following XML to the file:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

Update: I found a working example, you can refer to it.

Alexandar May - MSFT
  • 6,536
  • 1
  • 8
  • 15
  • Is the dictionary supposed to remain empty? I added the file but get the same errors – Stephen York Aug 23 '22 at 03:04
  • Yes, you can refer to [this link](https://learn.microsoft.com/en-us/dotnet/maui/ios/deployment/entitlements#add-an-entitlementsplist-file) and you can also copy the `Entitlements.plist` file from your working Xamarin.Forms iOS app. BTW, how do you configure the `sqlite pcl` in your MAUI project? Could you please create a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) via github repo? – Alexandar May - MSFT Aug 23 '22 at 06:11
  • I'll put together a reproducible example, but the app works fine in the android emulator and on android. The system does work, just something about iOS. Will get an example going – Stephen York Aug 23 '22 at 08:19
  • I created a new project and modified nothing at all and it deployed to the iPhone and runs fine. So that eliminates Entitlements being a requirement for deployment. – Stephen York Aug 24 '22 at 04:35
  • Then the issue should be related with the `sqlite pcl` in your MAUI project. – Alexandar May - MSFT Aug 24 '22 at 05:51
  • It's strange, my demo minimal demo I put together wasn't working, but as soon as I put the entitlements.plist in with an empyu element it worked... grizzle. Can't explain why it's not in my main project. But then now I can't run my main project anymore .... – Stephen York Aug 24 '22 at 06:23
  • ... getting this now. ```Deploy Error: Could not install the application 'C:\Users\.........\Logbook.ipa' on the device You Bute Communications Device. Details: MismatchedApplicationIdentifierEntitlement - Upgrade's application-identifier entitlement string (K4Rxxxxxx.com.myorg.logbook) does not match installed application's application-identifier string (53Bxxxxxx.com.myorg.logbook); rejecting upgrade.```. I'm seriously getting worn down over all the issues that can randomly occur with this platform. It's why I gave up on Xamarin years ago. Trying to not let go this time. – Stephen York Aug 24 '22 at 06:24
  • I've edited the original post to include the reproduceable example. – Stephen York Aug 24 '22 at 12:44
  • I'm sorry, but I don't see how the working example is equivalent to the issue I'm having. The errors I showed in my post clearly show that EntityFrameworkCore is unable to load. That example you added doesn't use EF. Have you looked at my reproduceable example? – Stephen York Aug 28 '22 at 00:12
  • I'm sorry that using `EntityFrameworkCore` is beyond my scope. – Alexandar May - MSFT Sep 13 '22 at 07:51
  • Is there anyone within Microsoft for whom it is in scope? – Stephen York Sep 13 '22 at 15:23
  • I found a [similar thread](https://stackoverflow.com/questions/72598734/entity-framework-core-in-net-maui-xamarin-forms) that may be helpful. If it still doesn't work, you can also ask a question in [this thread](https://learn.microsoft.com/en-us/answers/index.html). – Alexandar May - MSFT Sep 14 '22 at 06:16