Could not find method due to a type load error

1.3k views Asked by At

I am building an app with Xamarin and Breez# use VS2017 for Mac, all goes fine till VS2017 notified me there are updates yesterday, then I updated it, also the package of Xamarin.forms from nugget.

then my app cannot work. and throw an exception when trying to call a method to get data.

{System.TypeLoadException: Could not find method due to a type load error 
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder
`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x0002c] in 
/Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11
/src/mono/mcs/class/referencesource/mscorlib/system/runtime
/compilerservices/AsyncMethodBuilder.cs:471 

the method:

 public async Task<IEnumerable<Tenant>> GetAllItems()
    {
        try
        {
            // ignore the flurry of events when query results arrive
            _ignoreEntityChanged = true;
            var query = new EntityQuery<Tenant>().From(_resourceName);

            var qr = await _em.ExecuteQuery(query);
            _ignoreEntityChanged = false;
            var result = qr.ToList();

            return result;

        }
        catch (Exception e)
        {
            _ignoreEntityChanged = false;
            return new List<Tenant>(); // return empty result instead
        }
    }

every time when I try to step into this method, the error come out. and then I tried comment all the lines but only return an empty list, I can step into the method and it works. the next step, I uncomment the line:

var query = new EntityQuery<Tenant>().From(_resourceName);

then I cannot step into the method, and the error throws.

I suppose the EntityQuery has something wrong with the newest vs2017 and Xamarin.Form, but no sure of that.

0

There are 0 answers