-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microsoft.EntityFrameworkCore.Sqlite 7 crash on iOS #16228
Comments
From @eerhardt on Thu, 18 Aug 2022 23:42:07 GMT I don't believe this is a NullabilityInfoContextSupport issue. When I ran your app I see the following exception being thrown: |
From @RobertoGFilho on Fri, 19 Aug 2022 12:18:28 GMT @eerhardt thanks for you attention! I'm using Visual Studio 17.3.1 for Windows 11 and real device iPhone 7plus with hotrestart. Only iOS this error happen! I have already worked with EFCore 3.1 and Xamarin for three plataforms and works well. On Xamarin configuration iOS is:
let me show what is happen on MAUI: 2022_08_19_09_02_50.mp4I've already add : NullabilityInfoContextSupport = true on project file but it doesn't work do you have any idea? |
From @eerhardt on Fri, 19 Aug 2022 16:22:42 GMT Can you list what version of
I'm using a mac with When running the app on an iPad simulator in Debug mode, the app works fine. When running with |
From @RobertoGFilho on Fri, 19 Aug 2022 20:39:34 GMT I'm using 6.0.8 I'm using a real device "iPhone 7" plus iSO version 15 .. in debug mode .. and hotrestar enable |
From @eerhardt on Fri, 19 Aug 2022 20:44:22 GMT What is the output of |
From @RobertoGFilho on Fri, 19 Aug 2022 21:00:45 GMT Installed Workload Ids Manifest Version Installation Sourcemaui-android 6.0.486/6.0.400 VS 17.3.32811.315 Use |
From @eerhardt on Wed, 24 Aug 2022 20:33:25 GMT Unfortunately, I can't repro this behavior. If I launch the app on a physical phone using VS for Mac, it works correctly. I don't see an exception being thrown. I'm not able to deploy any Maui app to a physical phone from VS on Windows for some reason, and I spent too much time trying to get it to work. I've given up. My suggestions for debugging this would be to get a binlog of the build and inspect the If a binlog doesn't help, inspecting the .dlls in something like ILSpy may help give a clue. Look for the code using this switch: |
From @eerhardt on Wed, 24 Aug 2022 22:11:14 GMT Another thing to look for is in the "Build" output (on a fresh build/install), look for the string Here's a snippet of my build output:
|
From @RobertoGFilho on Thu, 25 Aug 2022 12:11:56 GMT hey @eerhardt ! something very crazy is happen! When I use iOS emulator error disappear, but if i try real device "iPhone 7 Plus" happens error . see: 2022_08_25_09_10_06.mp4 |
From @RobertoGFilho on Thu, 25 Aug 2022 12:13:37 GMT I have tryed to change : System.Reflection.NullabilityInfoContext.IsSupported = true or false.. but error happens |
From @eerhardt on Thu, 25 Aug 2022 14:40:49 GMT
I've run the EFCore app both from VS for Mac preview on my mac, and from VS for Windows paired with my mac, to a physical iPhone 6S and can't repro this behavior. Can you try running the app on a different development machine? My guess is that there is something specific about your dev machine that is causing this. |
From @eerhardt on Thu, 25 Aug 2022 14:44:12 GMT One idea to try to figure this out:
The only thing I can guess is that somehow the |
From @RobertoGFilho on Mon, 05 Sep 2022 13:32:09 GMT hi @eerhardt same error here on iPhone 6S Plus and 7Plus, on real device |
From @eerhardt on Tue, 06 Sep 2022 15:38:32 GMT @RobertoGFilho - did you try the above to get a binlog? |
From @RobertoGFilho on Sat, 10 Sep 2022 22:14:06 GMT hi folks! WORKS: public class Person : ObservableObject DOESN'T WORK public class Person : ObservableObject |
From @ErikEJ on Sun, 11 Sep 2022 06:08:15 GMT What is ObservableObject? |
From @RobertoGFilho on Mon, 12 Sep 2022 11:22:29 GMT hi @ErikEJ , ObservableObject is from MVVMHelpers, you can remove this, but the same error will show up! This error happen only string properties on Model. Only iOS plataform. Please you can reproduce this erro on this demo : https://github.com/RobertoGFilho/EFCore |
From @RobertoGFilho on Mon, 12 Sep 2022 11:58:26 GMT
|
From @RobertoGFilho on Thu, 22 Sep 2022 14:07:42 GMT Hi @eerhardt ! I have done in different machine, the same error shows up! |
From @eerhardt on Thu, 22 Sep 2022 15:04:20 GMT Are you able to get a binlog? See dotnet/efcore#28773 (comment) |
From @RobertoGFilho on Sat, 24 Sep 2022 16:32:23 GMT Hi @eerhardt binlog files are bellow: |
From @eerhardt on Mon, 26 Sep 2022 17:56:08 GMT Hmm, unfortunately those logs don't contain much information. One thing I was able to confirm was that Did you delete the |
From @RobertoGFilho on Mon, 26 Sep 2022 20:28:01 GMT Hi @eerhardt this binlog wore created after: delete the bin and obj folders to ensure everything is clean. the problem is when we have a string property on Model. if i remove this property everythings works see: this error shows up only iOS.. Android and Windows, it's ok |
From @eerhardt on Mon, 26 Sep 2022 21:01:41 GMT I don't see why
|
From @rolfbjarne on Mon, 26 Sep 2022 21:15:58 GMT @RobertoGFilho just in order to narrow things down: do you get the same behavior if you use Visual Studio for Mac (on the Mac)? |
From @RobertoGFilho on Tue, 27 Sep 2022 11:54:09 GMT hi @rolfbjarne ! I just work on Visual Studio for Windows! i have shared this demo : https://github.com/RobertoGFilho/EFCore |
From @rolfbjarne on Tue, 27 Sep 2022 14:39:41 GMT We set
and the test project does not set @RobertoGFilho can you try adding this to your project: <PropertyGroup>
<NullabilityInfoContextSupport>true</NullabilityInfoContextSupport>
</PropertyGroup> and see if that works? |
From @eerhardt on Tue, 27 Sep 2022 14:55:55 GMT @rolfbjarne - the |
From @RobertoGFilho on Tue, 27 Sep 2022 16:55:32 GMT @rolfbjarne, @eerhardt i have already tryed , but it doesn't work |
From @rolfbjarne on Fri, 30 Sep 2022 13:34:12 GMT The test project from the initial description works fine when I run it on a Mac. The two binlogs (dotnet/efcore#28773 (comment), dotnet/efcore#28773 (comment)) come from a build that wasn't connected to the Mac, and thus only a very simple build was done. @RobertoGFilho, please connect to a mac, build again and get the binlog, or try directly on the Mac (using Visual Studio for Mac) to see if that works for you. |
I was able to reproduce the behavior that @RobertoGFilho is hitting. Building the provided sample on VS while remoting to my Mac causes the same exception to be thrown while deploying to a device (iPhone 12 running iOS 14.2.1) but does not throw on a simulator. Also, commenting out the string Name property on the Person Class causes the exception to not be thrown. |
Here is the binlog from my build: |
Hi @tj-devel709 ,you are correct. Thank you ! That's so important to convince my company migrate to MAUI with EFCore! |
Is there any more on this issue?? I have the EXACT same issue as it crashes when I have a string in the model. using System.ComponentModel.DataAnnotations.Schema;
namespace EFCoreTestDeploy.Data.Models;
[Table("vendor")]
public class Vendor
{
public int VendorId { get; set; }
**// If this is remarked out then no exception**
public string Description { get; set; }
public int VendorCategoryPrimary { get; set; }
} This is in a .NET MAUI test app with VS 17.4.0 Preview 4. |
hi @tj-devel709 do you have idea when it will be fixed? |
<!--DOESN'T WORKS on iOS-->
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0" />
<!--WORKS-->
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.11" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
<PackageReference Include="SQLitePCLRaw.core" Version="2.1.2" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.2" />
<PackageReference Include="SQLitePCLRaw.provider.dynamic_cdecl" Version="2.1.2" />
<PackageReference Include="SQLitePCLRaw.provider.sqlite3" Version="2.1.2" /> using Foundation;
using SQLitePCL;
namespace EFCore
{
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp()
{
//raw.SetProvider(new SQLite3Provider_sqlite3());
return MauiProgram.CreateMauiApp();
}
}
} references: https://vladislavantonyuk.azurewebsites.net/articles/Adding-SQLite-to-the-.NET-MAUI-application |
Have met this exception and worked around it inside
App has been approved and published to AppStore. |
using System.ComponentModel.DataAnnotations.Schema;
namespace EFCoreTestDeploy.Data.Models;
[Table("vendor")]
public class Vendor
{
public int VendorId { get; set; }
// If this is remarked out then no exception
public string Description { get; set; }
public int VendorCategoryPrimary { get; set; }
} This is in a .NET MAUI test app with VS 17.5.0 Preview 2. I STILL have the following error!! " NullabilityInfoContext is not supported in the current application because 'System.Reflection.NullabilityInfoContext.IsSupported' is set to false. Set the MSBuild Property 'NullabilityInfoContextSupport' to true in order to enable it. As suggested earlier I do have the following in the project file: <PropertyGroup>
<NullabilityInfoContextSupport>true</NullabilityInfoContextSupport>
<Nullable>enable</Nullable>
</PropertyGroup> Can someone please help with resolving this. It is a very simple use case. When EnsureCreated() is called then the error happens as described above in my previous post and of the earlier post where remarking out the "Description" string of the 'Vendor' Class and that makes this work. If the Model Class (Vendor in this case) has ANY string properties then the exception occurs upon doing the EnsureCreated() call. Otherwise if you have a Table model without any string properties then everything works perfectly. At this point it feels impossible to continue with App development on IOS until this is resolved!! Thanks, |
I have added a minimal GitHub project that illustrates the 'NullabilityInfoContext' issue with EnsureCreated() on a Physical IOS device only with EF Core and .NET Maui. |
@schlaman can you try your sample from the Mac directly using VS for Mac and see if that works? |
@rolfbjarne First of all thank you so much for your response!! I'm feeling very discouraged by this problem I've had for a long time now. I haven't been developing for the Mac but I can get the latest Visual Studio installed on my Mac and give it a try.**Also, one other note is that this doesn't always fail. Just virtually always with brief intermittent times of working when some kind of change is made (like the DB filename) ** Last night I was playing with adding in some of the other related NuGet packages that had been mentioned elsewhere as maybe solving the problem and then it worked. But I tried to repro by taking those back out and then it didn't work but then when I added the extra NuGets back in it still didn't work again. I couldn't make it work at all then. I then tried renaming the database Sqlite DB file I was creating and then ran it and it worked just fine. I then changed the name back and it stopped working. Then I changed the name back again to the new name and then it didn't work. I could not make it work from there. I don't know if I should have Nullability turned on and if so what I should be doing with the attributes for the Table model's string properties 'Vendor.Description' in this case. Is that somehow related to this issue? |
I am working on getting my mac setup to test this. Just figuring out certificates and such on it now. Is there anything else I can do to test this. I'm still working on getting the answer for the mac but this is a big time consumer for me to do that! |
I believe I figured out the problem, and it only happens when using Hot Restart from Windows. The underlying cause is that when using Hot Restart, the The workaround seems to be to force the runtime setting for AppContext.SetSwitch("System.Reflection.NullabilityInfoContext.IsSupported", true); and now the test project seems to work fine. |
This is an issue in VS for Windows, so I've filed https://developercommunity.visualstudio.com/t/For-iOS-builds-runtimeconfigbin-isnt-b/10259889?port=1025&fsid=26f22907-18bf-4765-9f85-d2c2569fd3aa with a simpler test case. Please vote/comment on that issue instead of this one for any questions or concerns. |
Thank you @rolfbjarne !! I GREATLY appreciate you looking into this and solving this issue!! You were guessing that perhaps the runtimeconfig.bin file was being copied from the prebuilt app instead of using the one produced during the build. If that is the case, are there further implications of other MSBuild properties being lost? Thanks again! |
Yes, there are a few others, but it's rare to change the default for most of these for mobile projects: https://github.com/dotnet/runtime/blob/main/docs/workflow/trimming/feature-switches.md |
Just an FYI. The NullabilityInfoContext was explicitly designed to be changed depending on the need. By default, this nullability info isn't needed in an app. So we trim it in order to make the app smaller. But some libraries really do need this info (EF.Core in this example). So when using EF.Core in an app will change the default so the information is preserved. Hopefully VS fixes this issue generally. |
@rolfbjarne , @eerhardt |
From @RobertoGFilho on Thu, 18 Aug 2022 11:03:24 GMT
EfCore 7 crash on iOS MAUI app. Please you can reproduce this erro on this demo : https://github.com/RobertoGFilho/EFCore
Visual studio 17.3.1
Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0-preview.7.22376.2"
Copied from original issue dotnet/efcore#28773
The text was updated successfully, but these errors were encountered: