Forum Xamarin.Forms

Error when I try open app using Entity Framework

Hi I have an app on the test channel of the play store, it was work fine, but I solved use Entity Framework, when I released a version the app stoped to work, on Visual Studio run normally but if I install using apk file and try open it not work.
When I install app using abd shell and I get the follow stacktrace:

:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=br.com.arasolution.trackermobile/md5fe955b898135a8fb7f26617b645b333c.MainActivity;end
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=br.com.arasolution.trackermobile/md5fe955b898135a8fb7f26617b645b333c.MainActivity } in package br.com.arasolution.trackermobile
    // Rejecting start of Intent { cmp=com.samsung.android.app.galaxyfinder/.GalaxyFinderActivity } in package com.samsung.android.app.galaxyfinder
:Sending Touch (ACTION_DOWN): 0:(62.0,1345.0)
    // Injection Failed
    // Injection Failed
:Sending Touch (ACTION_UP): 0:(63.430508,1346.4381)
    // Injection Failed
:Sending Touch (ACTION_DOWN): 0:(439.0,755.0)
    // Injection Failed
    // Injection Failed
    // Injection Failed
    // Injection Failed
    // Injection Failed
    // Injection Failed
    // Injection Failed
    // Injection Failed
    // Injection Failed
:Sending Touch (ACTION_UP): 0:(552.60547,713.5607)
    // Injection Failed
    // Rejecting start of Intent { act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.google.android.packageinstaller cmp=com.google.android.packageinstaller/com.android.packageinstaller.permission.ui.GrantPermissionsActivity } in package com.google.android.packageinstaller
// CRASH: br.com.arasolution.trackermobile (pid 25057)
// Short Msg: android.runtime.JavaProxyThrowable
// Long Msg: android.runtime.JavaProxyThrowable: System.ArgumentException: The method 'b[Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder`1[Microsoft.EntityFrameworkCore.Migrations.Operations.AddColumnOperation],Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder`1[Microsoft.EntityFrameworkCore.Migrations.Operations.AddColumnOperation]].c' is not a property accessor
Parameter name: propertyAccessor
  at System.Linq.Expressions.Expression.GetProperty (System.Reflection.MethodInfo mi, System.String paramName, System.Int32 index) [0x00088] in <ba85ba5122c3499483c4d8a7ac6f7e5a>:0
  at System.Linq.Expressions.Expression.Property (System.Linq.Expressions.Expression expression, System.Reflection.MethodInfo propertyAccessor) [0x00016] in <ba85ba5122c3499483c4d8a7ac6f7e5a>:0
  at TrackerMobile.Migracoes.Migrations.MigracaoInicial+<>c.a (Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.CreateTableBuilder`1[TColumns] A_0) [0x0002b] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
  at Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder.CreateTable[TColumns] (System.String name, System.Func`2[T,TResult] columns, System.String schema, System.Action`1[T] constraints) [0x000cb] in <69f795dffc844780bfcfff4ff8415a92>:0
  at TrackerMobile.Migracoes.Migrations.MigracaoInicial.Up (Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder migrationBuilder) [0x00000] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
  at Microsoft.EntityFrameworkCore.Migrations.Migration.BuildOperations (System.Action`1[T] buildAction) [0x0000c] in <69f795dffc844780bfcfff4ff8415a92>:0
  at Microsoft.EntityFrameworkCore.Migrations.Migration.<.ctor>b__4_1 () [0x0000e] in <69f795dffc844780bfcfff4ff8415a92>:0
  at Microsoft.EntityFrameworkCore.Internal.LazyRef`1[T].get_Value () [0x00008] in <adf771f92e754fe1bb85c5850cd0c16b>:0
  at Microsoft.EntityFrameworkCore.Migrations.Migration.get_UpOperations () [0x00000] in <69f795dffc844780bfcfff4ff8415a92>:0
  at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateUpSql (Microsoft.EntityFrameworkCore.Migrations.Migration migration) [0x00033] in <69f795dffc844780bfcfff4ff8415a92>:0
  at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator+<>c__DisplayClass13_2.<GetMigrationCommandLists>b__2 () [0x00026] in <69f795dffc844780bfcfff4ff8415a92>:0
  at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate (System.String targetMigration) [0x0007a] in <69f795dffc844780bfcfff4ff8415a92>:0
  at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate (Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade) [0x00010] in <69f795dffc844780bfcfff4ff8415a92>:0
  at TrackerMobile.DB.IAppDbContext..ctor (Microsoft.EntityFrameworkCore.DbContextOptions`1[TContext] options) [0x0007f] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
  at TrackerMobile.DB.AppDbContext..ctor (Microsoft.EntityFrameworkCore.DbContextOptions`1[TContext] options) [0x00000] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
  at TrackerMobile.Forms.ViewModels.LoginViewModel.d () [0x00026] in <616f42fbee9f4a8091394a539e521ece>:0
  at TrackerMobile.Forms.ViewModels.LoginViewModel.OnAppearing () [0x00000] in <616f42fbee9f4a8091394a539e521ece>:0
  at Prism.Behaviors.PageLifeCycleAwareBehavior+<>c.<OnAppearing>b__2_0 (Prism.AppModel.IPageLifecycleAware aware) [0x00000] in <67be6ca629f141368fde5ee65f270d8b>:0
  at Prism.Common.PageUtilities.InvokeViewAndViewModelAction[T] (System.Object view, System.Action`1[T] action) [0x0003e] in <67be6ca629f141368fde5ee65f270d8b>:0
  at Prism.Behaviors.PageLifeCycleAwareBehavior.OnAppearing (System.Object sender, System.EventArgs e) [0x00006] in <67be6ca629f141368fde5ee65f270d8b>:0
  at Xamarin.Forms.Page.SendAppearing () [0x00034] in <a9131f61340149fcbb08ad43ae808046>:0
  at Xamarin.Forms.Page.SendAppearing () [0x00056] in <a9131f61340149fcbb08ad43ae808046>:0
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnAttachedToWindow () [0x0000c] in <e11d74a01fc148949d5e89708470f54c>:0
  at Android.Views.View.n_OnAttachedToWindow (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <2960acf2eeb24d88b5230e1e8afbdc2e>:0
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.34(intptr,intptr)
// Build Label: samsung/on7xelteub/on7xelte:8.1.0/M1AJQ/G610MUBS4CSB4:user/release-keys
// Build Changelist: G610MUBS4CSB4
// Build Time: 1550493190000
// android.runtime.JavaProxyThrowable: System.ArgumentException: The method 'b[Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder`1[Microsoft.EntityFrameworkCore.Migrations.Operations.AddColumnOperation],Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder`1[Microsoft.EntityFrameworkCore.Migrations.Operations.AddColumnOperation]].c' is not a property accessor
// Parameter name: propertyAccessor
//   at System.Linq.Expressions.Expression.GetProperty (System.Reflection.MethodInfo mi, System.String paramName, System.Int32 index) [0x00088] in <ba85ba5122c3499483c4d8a7ac6f7e5a>:0
//   at System.Linq.Expressions.Expression.Property (System.Linq.Expressions.Expression expression, System.Reflection.MethodInfo propertyAccessor) [0x00016] in <ba85ba5122c3499483c4d8a7ac6f7e5a>:0
//   at TrackerMobile.Migracoes.Migrations.MigracaoInicial+<>c.a (Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.CreateTableBuilder`1[TColumns] A_0) [0x0002b] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
//   at Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder.CreateTable[TColumns] (System.String name, System.Func`2[T,TResult] columns, System.String schema, System.Action`1[T] constraints) [0x000cb] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at TrackerMobile.Migracoes.Migrations.MigracaoInicial.Up (Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder migrationBuilder) [0x00000] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
//   at Microsoft.EntityFrameworkCore.Migrations.Migration.BuildOperations (System.Action`1[T] buildAction) [0x0000c] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at Microsoft.EntityFrameworkCore.Migrations.Migration.<.ctor>b__4_1 () [0x0000e] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at Microsoft.EntityFrameworkCore.Internal.LazyRef`1[T].get_Value () [0x00008] in <adf771f92e754fe1bb85c5850cd0c16b>:0
//   at Microsoft.EntityFrameworkCore.Migrations.Migration.get_UpOperations () [0x00000] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateUpSql (Microsoft.EntityFrameworkCore.Migrations.Migration migration) [0x00033] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator+<>c__DisplayClass13_2.<GetMigrationCommandLists>b__2 () [0x00026] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate (System.String targetMigration) [0x0007a] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate (Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade) [0x00010] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at TrackerMobile.DB.IAppDbContext..ctor (Microsoft.EntityFrameworkCore.DbContextOptions`1[TContext] options) [0x0007f] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
//   at TrackerMobile.DB.AppDbContext..ctor (Microsoft.EntityFrameworkCore.DbContextOptions`1[TContext] options) [0x00000] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
//   at TrackerMobile.Forms.ViewModels.LoginViewModel.d () [0x00026] in <616f42fbee9f4a8091394a539e521ece>:0
//   at TrackerMobile.Forms.ViewModels.LoginViewModel.OnAppearing () [0x00000] in <616f42fbee9f4a8091394a539e521ece>:0
//   at Prism.Behaviors.PageLifeCycleAwareBehavior+<>c.<OnAppearing>b__2_0 (Prism.AppModel.IPageLifecycleAware aware) [0x00000] in <67be6ca629f141368fde5ee65f270d8b>:0
//   at Prism.Common.PageUtilities.InvokeViewAndViewModelAction[T] (System.Object view, System.Action`1[T] action) [0x0003e] in <67be6ca629f141368fde5ee65f270d8b>:0
//   at Prism.Behaviors.PageLifeCycleAwareBehavior.OnAppearing (System.Object sender, System.EventArgs e) [0x00006] in <67be6ca629f141368fde5ee65f270d8b>:0
//   at Xamarin.Forms.Page.SendAppearing () [0x00034] in <a9131f61340149fcbb08ad43ae808046>:0
//   at Xamarin.Forms.Page.SendAppearing () [0x00056] in <a9131f61340149fcbb08ad43ae808046>:0
//   at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnAttachedToWindow () [0x0000c] in <e11d74a01fc148949d5e89708470f54c>:0
//   at Android.Views.View.n_OnAttachedToWindow (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <2960acf2eeb24d88b5230e1e8afbdc2e>:0
//   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.34(intptr,intptr)
//      at md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer.n_onAttachedToWindow(Native Method)
//      at md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer.onAttachedToWindow(NavigationPageRenderer.java:49)
//      at android.view.View.dispatchAttachedToWindow(View.java:18728)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3534)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2186)
//      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1863)
//      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8072)
//      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
//      at android.view.Choreographer.doCallbacks(Choreographer.java:723)
//      at android.view.Choreographer.doFrame(Choreographer.java:658)
//      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
//      at android.os.Handler.handleCallback(Handler.java:790)
//      at android.os.Handler.dispatchMessage(Handler.java:99)
//      at android.os.Looper.loop(Looper.java:164)
//      at android.app.ActivityThread.main(ActivityThread.java:7000)
//      at java.lang.reflect.Method.invoke(Native Method)
//      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
//      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
//
** Monkey aborted due to error.
Events injected: 19
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=13 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=8207ms (0ms mobile, 0ms wifi, 8207ms not connected)
** System appears to have crashed at event 19 of 500 using seed 1555759346990

It's looks like for me who a project lost references to Entity Framework, when app start it try run migration, follow my code:

public partial class App : PrismApplication
    {

    // omitted default constructors

        protected override async void OnInitialized()
        {
            InitializeComponent();
            //TODO: depois que lançar versão oficial do app remover essa rotina de exclusão de banco de dados
            using (IAppDbContext db = new AppDbContext(new DbContextOptionsBuilder<IAppDbContext>().UseSqlite(new SqliteConnection(Container.Resolve<IDBUtils>().ObterCaminhoBanco())).Options))
            {
                using (DbConnection conn = db.Database.GetDbConnection())
                {
                    if (conn.State.Equals(ConnectionState.Closed))
                    {
                        conn.Open();
                    }
                    using (var command = conn.CreateCommand())
                    {
                        command.CommandText = @"Select Count(name) from sqlite_master where type = 'table' and  name = 'Sessoes';";
                        bool baseNaoMigrada = !Convert.ToBoolean(command.ExecuteScalar());
                        if (baseNaoMigrada)
                        {
                            db.Database.EnsureDeleted();
                        }
                    }
                }
            }

            using (IAppDbContext db = new AppDbContext(new DbContextOptionsBuilder<IAppDbContext>().UseSqlite(new SqliteConnection(Container.Resolve<IDBUtils>().ObterCaminhoBanco())).Options))
            {
                db.Database.Migrate();
            }
            string pagina = SessaoUsuario.UsuarioEstaLogado ? string.Format("/" + ViewsNamesConstants.PREFIXO_VIEW_MASTER_DETAIL, ViewsNamesConstants.MASTER_DETAIL, ViewsNamesConstants.MAPA) : string.Format(ViewsNamesConstants.PREFIXO_VIEW, ViewsNamesConstants.LOGIN);
            await NavigationService.NavigateAsync(pagina);
        }

         // omitted OnResume, OnSleep and RegisterTypes
    }

thank you :)

Answers

  • JoséJuniorJoséJunior Member ✭✭

    Have some configuration I need to do in Release? I didn't understand because in Debug my app work fine

  • TakeShikaTakeShika Member ✭✭

    Had the same following errors:
    // android.runtime.JavaProxyThrowable: System.ArgumentException: The method 'b[Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder1[Microsoft.EntityFrameworkCore.Migrations.Operations.AddColumnOperation],Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder1[Microsoft.EntityFrameworkCore.Migrations.Operations.AddColumnOperation]].c' is not a property accessor
    // Parameter name: propertyAccessor .......

    In my case, the combination of dotfuscator and ef was doing all the trouble.

    How solved:
    1. Make a new .net standard library project in the solution.
    2. Reference that project, and move ALL code files related to ef to the new project.
    3. Open dotfuscator GUI (from "Tools") and exclude the entire dll file for the new project from renaming.
    Open your DotfuscatorConfig -> Renaming -> Exclusions -> check the new project dll

    If you can't find the dll on step 3, try the following

    1. Editing your csproj. Find this line...
      false

    and change it to true
    true

    1. Rename your DotfuscatorConfig file something like DotfuscatorConfig_bkup

    2. Compile your app and let VS rebuild the config file. The compile itself will most likely fail.

    3. Revert step 1 (change back to false)

Sign In or Register to comment.