我使用此代码获取一些 Json 文本:
response = await _httpClient.GetAsync(Gurl).ConfigureAwait(false);
Gurl 是正确的。这在 IOS 模拟器上运行良好,但在 Android 中不起作用。
在android中,如果我这样调用页面,它会起作用:
Navigation.PushModalAsync(new NavigationPage(new Gallery()));
或像这样:
Navigation.PushAsync(new NavigationPage(new Gallery()));
但如果我这样调用页面则不起作用:
Navigation.PushAsync(new Gallery());
在IOS中所有3个工作。但我需要它是非模态的,以便在 IOS 中有后退按钮。
我得到的错误是:
The application is in break mode
Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code).
System.NullReferenceException: 'Object reference not set to an instance of an object.'
我通过添加断点找到了导致问题的行,直到找到它不继续的地方。
调用堆栈只说[external code]
,输出说:
04-02 20:50:16.957 D/Mono ( 4825): Requesting loading reference 1 (of 3) of System.Net.Http.dll
04-02 20:50:16.957 D/Mono ( 4825): Loading reference 1 of System.Net.Http.dll asmctx DEFAULT, looking for System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
04-02 20:50:16.957 D/Mono ( 4825): Assembly Ref addref System.Net.Http[0xcc240e40] -> System[0xe78226a0]: 13
04-02 20:50:16.963 D/Mono ( 4825): Requesting loading reference 2 (of 8) of Mono.Android.dll
04-02 20:50:16.963 D/Mono ( 4825): Loading reference 2 of Mono.Android.dll asmctx DEFAULT, looking for System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
04-02 20:50:16.964 D/Mono ( 4825): Assembly Ref addref Mono.Android[0xe7822580] -> System.Net.Http[0xcc240e40]: 3
[0:] Binding: 'isBusy' property not found on 'GalShare.ViewModel.GalleryViewModel', target property: 'Xamarin.Forms.StackLayout.IsVisible'
04-02 20:50:17.118 W/nyname.galshar( 4825): Accessing hidden field Landroid/view/animation/Animation;->mListener:Landroid/view/animation/Animation$AnimationListener; (light greylist, reflection)
04-02 20:50:17.136 W/nyname.galshar( 4825): JNI RegisterNativeMethods: attempt to register 0 native methods for crc643f46942d9dd1fff9.ActivityIndicatorRenderer
04-02 20:50:17.282 D/NetworkSecurityConfig( 4825): No Network Security Config specified, using platform default
Thread started: <Thread Pool> #9
**System.NullReferenceException:** 'Object reference not set to an instance of an object.'