locked
Could not load type IAsyncStateMechine RRS feed

  • Question

  • User2943 posted

    Hello.

    I've just installed recently announced toolkit and created a solution which contains: - Android Application project - Class Library project

    Class library project uses SQLite-net and SQLiteAsyncConnection and its async methods. When trying to call such async method I get the exception:

    Unhandled Exception:

    System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.IAsyncStateMachine' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Loaded assembly: System.dll [External] 02-22 21:03:02.859 I/MonoDroid( 3915): UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.IAsyncStateMachine' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 02-22 21:03:02.859 I/MonoDroid( 3915): at ILikeCoins.Android.Fragments.CoinListFragment.OnCreate (Android.OS.Bundle) [0x00041] in c:\Projects\ILikeCoins\ILikeCoins.Android\Fragments\CoinListFragment.cs:37 02-22 21:03:02.859 I/MonoDroid( 3915): at Android.Support.V4.App.Fragment.nOnCreateLandroidosBundle_ (intptr,intptr,intptr) [0x00010] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid-bindings/Compatibility-v4/bindings/obj/platform-8/src/generated/Android.Support.V4.App.Fragment.cs:829 02-22 21:03:02.859 I/MonoDroid( 3915): at (wrapper dynamic-method) object.51b216eb-dcb8-4c6c-91a0-1d9146c13431 (intptr,intptr,intptr)

    Could anybody explain what am I doing wrong and how this can be solved?

    The code which is executed:

    _database.LoadCategories();
    ...
    public async void LoadCategories()
    {
         IList result = await Database.QueryCategories().ToListAsync();
         if (CategoryListLoaded != null) CategoryListLoaded(result);
     }
    ...
    public AsyncTableQuery QueryCategories()
    {
        return Table<Category>();
    }
    

    Environment: Windows 8 x64, Visual Studio 2012, Xamarin Android 4.6.00049

    Friday, February 22, 2013 7:14 PM

All replies

  • User48 posted

    Could anybody explain what am I doing wrong and how this can be solved?

    What you're doing wrong is using C#5 async.

    This can be solved by waiting ~2 months for us to actually support C#5 async: we've announced that we will support C#5 async at our Evolve conference. Alternatively you can use Task.ContinueWith() instead of async.

    Friday, February 22, 2013 10:03 PM
  • User2029 posted

    Would love to debug C# async for you

    Tuesday, March 5, 2013 7:33 PM