大家好,我正在编写一个跨平台应用程序,需要从url端点获取一些数据,这是方法:
/// <summary>
/// Ottiene tutte le informazioni visualizzabili nell'applicazione
/// </summary>
/// <returns></returns>
public async Task ottieniInformazioniAsync() {
if (contentDownloaded)
return;
Action action = () => { ottieniInformazioniAsync(); };
this.wrapper = await PersistanceStorage.PersistanceStorage.Instance.getInformations();
if (wrapper == null)
await App.showAwaitableMessage("Si è verificato un errore nell'ottenimento delle informazioni.", "Errore", "Riprova", action);
else
contentDownloaded = true;
this.wrapper.generaOggetto(this);
}
我在调用* PersistanceStorage.PersistanceStorage.Instance.getInformations(); *方法的地方开始崩溃,这是正文:
/// <summary>
/// Ottiene tutte le informazioni dalla base di dati
/// </summary>
/// <returns></returns>
public async Task<InformationContainer.InformationWrapper> getInformations() {
var url = URLREST + "/getInformazioni";
var request = await requestData(url);
if (request.IsSuccessStatusCode)
{
try
{
var content = await request.Content.ReadAsStringAsync();
var wrapper = JsonConvert.DeserializeObject<InformationCallWrapper>(content);
return wrapper.data;
}
catch (Exception e)
{
Debug.WriteLine("Errore download informazioni" + e);
}
}
return null;
}
仅当我在android上运行该应用程序时,并且仅在该应用程序的第一次运行中,所有崩溃都会调用 await requestData(url);方法:
/// <summary>
/// Effettua una richiesta http ad una risorsa
/// </summary>
/// <returns>The data.</returns>
/// <param name="url">URL.</param>
public async Task<HttpResponseMessage> requestData(String url)
{
var uri = new Uri(string.Format(url, string.Empty));
try
{
return await RestClient.GetAsync(uri);
}
catch (Exception e) {
Debug.WriteLine(e);
return null;
}
}
这是堆栈跟踪:
[Mono] Loading reference 2 of System.Net.Http.dll asmctx DEFAULT, looking for System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
[Mono] Assembly Ref addref System.Net.Http[0x74a6364880] -> System.Core[0x74ade3bb00]: 11
[capitale.ctsap] 0xebadde09 skipped times: 0
[mono-rt] /proc/self/maps:
[mono-rt] 12c00000-12f80000 rw-p 00000000 00:01 19984 /dev/ashmem/dalvik-main space (region space)_3233_3233 (deleted)
[mono-rt] 12f80000-13080000 ---p 00380000 00:01 19984 /dev/ashmem/dalvik-main space (region space)_3233_3233 (deleted)
[mono-rt] 13080000-13180000 rw-p 00480000 00:01 19984 /dev/ashmem/dalvik-main space (region space)_3233_3233 (deleted)
[mono-rt] 13180000-134c0000 rw-p 00580000 00:01 19984 /dev/ashmem/dalvik-main space (region space)_3233_3233 (deleted)
[mono-rt] 134c0000-13540000 ---p 008c0000 00:01 19984 /dev/ashmem/dalvik-main space (region space)_3233_3233 (deleted)
[mono-rt] 13540000-13580000 rw-p 00940000 00:01 19984 /dev/ashmem/dalvik-main space (region space)_3233_3233 (deleted)
[mono-rt] 13580000-13940000 ---p 00980000 00:01 19984 /dev/ashmem/dalvik-main space (region space)_3233_3233 (deleted)
[mono-rt] 13940000-13980000 rw-p 00d40000 00:01 19984 /dev/ashmem/dalvik-main space (region space)_3233_3233 (deleted)
[mono-rt] 13980000-14080000 ---p 00d80000 00:01 19984 /dev/ashmem/dalvik-main space (region space)_3233_3233 (deleted)
[mono-rt] 14080000-140c0000 rw-p 01480000 00:01 19984 /dev/ashmem/dalvik-main space (region space)_3233_3233 (deleted)
[mono-rt] 140c0000-14100000 ---p 014c0000 00:01 19984 /dev/ashmem/dalvik-main space (region space)_3233_3233 (deleted)
[mono-rt] 14100000-2ac00000 rw-p 01500000 00:01 19984 /dev/ashmem/dalvik-main space (region space)_3233_3233 (deleted)
[mono-rt] 6f28d000-6f567000 rw-p 00000000 fe:01 79 /data/dalvik-cache/arm64/system@framework@boot.art
[mono-rt] 6f567000-6f57d000 r--p 002da000 fe:01 79 /data/dalvik-cache/arm64/system@framework@boot.art
[mono-rt] 6f57d000-6f6b2000 rw-p 00000000 fe:01 89 /data/dalvik-cache/arm64/system@framework@boot-core-libart.art
[mono-rt] 6f6b2000-6f6c4000 r--p 00135000 fe:01 89 /data/dalvik-cache/arm64/system@framework@boot-core-libart.art
[mono-rt] 6f6c4000-6f704000 rw-p 00000000 fe:01 98 /data/dalvik-cache/arm64/system@framework@boot-conscrypt.art
[mono-rt] 6f704000-6f707000 r--p 00040000 fe:01 98 /data/dalvik-cache/arm64/system@framework@boot-conscrypt.art
[mono-rt] 6f707000-6f74e000 rw-p 00000000 fe:01 103 /data/dalvik-cache/arm64/system@framework@boot-okhttp.art
[mono-rt] 6f74e000-6f752000 r--p 00047000 fe:01 103 /data/dalvik-cache/arm64/system@framework@boot-okhttp.art
[mono-rt] 6f752000-6f7b8000 rw-p 00000000 fe:01 114 /data/dalvik-cache/arm64/system@framework@boot-bouncycastle.art
[mono-rt] 6f7b8000-6f7bf000 r--p 00066000 fe:01 114 /data/dalvik-cache/arm64/system@framework@boot-bouncycastle.art
[mono-rt] 6f7bf000-6f820000 rw-p 00000000 fe:01 117 /data/dalvik-cache/arm64/system@framework@boot-apache-xml.art
[mono-rt] 6f820000-6f827000 r--p 00061000 fe:01 117 /data/dalvik-cache/arm64/system@framework@boot-apache-xml.art
[mono-rt] 6f827000-6f86b000 rw-p 00000000 fe:01 121
/data/dalvik-cache/arm64/system@framework@boot-ext.art
[libc] Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7fe3f58cf0 in tid 24999 (capitale.ctsapp), pid 24999 (capitale.ctsapp)
我不明白为什么崩溃仅在首次启动时才发生,并且仅在Android平台上发生,也许有些权限或块丢失了吗?