Skip to content
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

Xamarin IOS ArgumentNullException in full linking mode. (EntityFrameworkCore.Sqlite) #24788

Closed
gyb001 opened this issue Apr 27, 2021 · 2 comments

Comments

@gyb001
Copy link

gyb001 commented Apr 27, 2021

I have a Xamarin IOS/Android app which use EntityFreamworkCoreSqlite 5.0.5.
Trying make full linked version. Android is ok, after read this: Issue and add AndroidLinkSkip to Csproj.
But in ios i'm unable to run app with Link All. Work fine in Dont Link and Link Freamwork SDK only. Therefore i think it Linker problem.
No matter that run in Release / Debug / Simulator / RealDevice
When i use the db context for data modification i got exception. like: _context.RemoveRange(_context.poi); or _context.AddRange(newPoi); (_newPoi has correct value and work in android Full link, ios Dont Link and ios Link Freamwork SDK)

Exception: (Full)

Unhandled Exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: source
  at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T] (T value, System.String parameterName) [0x00014] in <60b4caed95534d9e9bba8e623d3661ff>:0 
  at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.Include[TEntity,TProperty] (System.Linq.IQueryable1[T] source, System.Linq.Expressions.Expression1[TDelegate] navigationPropertyPath) [0x00000] in <60b4caed95534d9e9bba8e623d3661ff>:0 
  at myapp.App.Update (System.Threading.Tasks.Task1[TResult] retval) [0x0035b] in F:\a\myapp\myapp\App.xaml.cs:123

When trying to get data from database return null.
Install app in Dont Link mode. First time create the sqlite db, and seed the it with data. After a lot of restert everything is fine. Image
Change to Full Link mode and run again(whitout delete app and keep sqlite.db file). Context always return null. Image
Change back Dont link mode (whitout delete app and keep sqlite.db file) work again.

IOS.csproj
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
    <DefineConstants>DEBUG</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <MtouchArch>x86_64</MtouchArch>
    <MtouchLink>Full</MtouchLink>
    <MtouchDebug>true</MtouchDebug>
    <CodesignKey>iPhone Developer</CodesignKey>
    <CodesignProvision>
    </CodesignProvision>
    <MtouchFloat32>true</MtouchFloat32>
    <MtouchFastDev>true</MtouchFastDev>
    <MtouchSdkVersion>14.4</MtouchSdkVersion>
    <OptimizePNGs>false</OptimizePNGs>
    <MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
    <MtouchNoSymbolStrip>false</MtouchNoSymbolStrip>
    <MtouchEnableSGenConc>false</MtouchEnableSGenConc>
    <MtouchExtraArgs> --linkskip=Microsoft.EntityFrameworkCore --linkskip=Microsoft.EntityFrameworkCore.Relational --linkskip=Microsoft.EntityFrameworkCore.Sqlite --linkskip=Remotion.Linq --linkskip=Microsoft.Data.Sqlite.Core --linkskip=Microsoft.EntityFrameworkCore.Sqlite.Core --linkskip=Microsoft.Extensions.DependencyInjection.Abstractions --linkskip=Microsoft.Extensions.DependencyInjection --linkskip=Microsoft.Extensions.Logging.Abstractions --linkskip=Microsoft.Extensions.Logging --linkskip=Microsoft.Extensions.Caching.Abstractions --linkskip=Microsoft.Extensions.Caching.Memory --linkskip=Microsoft.Extensions.Options --linkskip=Microsoft.Extensions.Primitives --linkskip=System.Reflection --linkskip=System.Reflection.Primitives --linkskip=System.Linq --linkskip=System.Linq.Expressions --linkskip=System.Linq.Queryable  --linkskip=System.Text.Json</MtouchExtraArgs>
  </PropertyGroup>

LinkerDescription

  <ItemGroup>
    <LinkDescription Include="LinkDescription.xml">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </LinkDescription>
  </ItemGroup>
Shared project: 
  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
	<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <ProduceReferenceAssembly>true</ProduceReferenceAssembly>
    <RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <WarningLevel>0</WarningLevel>
	
    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.5" />
    <PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
  </ItemGroup>
AppDelegate
  public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            SQLitePCL.Batteries.Init();

Latest VS 2019 community and 2019 Enterprise Preview

Any tipp?

@ajcvickers
Copy link
Contributor

Related: #10963

@ajcvickers
Copy link
Contributor

Verified that this is a duplicate of #10963.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants