간헐적으로 Encoding.ASCII.GetString 호출이 실패하고 모든 catch 블록을 이스케이프 처리하여 응용 프로그램을 고정시킵니다. 4메가바이트 - 내가 얻을MonoDroid : Encoding.ASCII.GetString failing
private string ExecuteRequest(Uri url, KeyValuePair<string, string>[] postItems = null)
{
var data = new byte[0];
var response = new byte[0];
using (var client = new WebClient())
{
if (postItems != null && postItems.Count() > 0)
{
string dataString = string.Join("&", postItems.Select(
item => string.Format("{0}={1}", item.Key, item.Value)).ToArray());
data = new ASCIIEncoding().GetBytes(dataString);
}
response = client.UploadData(url, "POST", data);
Android.Util.Log.Info("info", "response from the post received. about to get string");
client.Dispose();
}
try
{
return Encoding.ASCII.GetString(response);
}
catch (Exception ex)
{
Android.Util.Log.Info("info",
"Encoding.ASCII.GetString Exception : {0}, {1}", ex.Message, ex.StackTrace);
throw new ApplicationException("UnRecoverable. Abort");
}
}
스택 트레이스 1 사이의 범위 수 JSON 데이터가 내가
I/mono (9817): Stacktrace:
I/mono (9817):
F/ (9817): * Assertion at ../../../../mono/mini/mini-exceptions.c:472, condition `class' not met
D/dalvikvm( 220): GC_EXPLICIT freed 1K, 35% free 17547K/26759K, paused 3ms+3ms
응답 아래에 나타낸 대한 unusal 스택 트레이스를 얻고,이 intermitently
I/sssvida (10960): response from the post received. about to get string
I/mono (10960): Stacktrace:
I/mono (10960):
I/mono (10960): at System.Text.ASCIIEncoding.GetString (byte[],int,int) <0x000cb>
I/mono (10960): at System.Text.Encoding.GetString (byte[]) <0x00037>
I/mono (10960): at ServiceRequest.ExecuteRequest (System.Uri,System.Collections.Generic.KeyValuePair`2<string, string>[]) <0x0026b>
입니다.
도와주세요. 감사!!!!
편집 2 : 나는 UploadString 대신 UploadData를 사용하도록 코드를 업데이트하고 간헐적으로 나는이 얻을 : 롤프는 의견 요청으로
I/mono (15065): Stacktrace:
I/mono (15065):
I/mono (15065): at string.CreateString (char[]) <0x0004b>
I/mono (15065): at (wrapper managed-to-managed) string..ctor (char[]) <0xffffffff>
I/mono (15065): at System.Text.Encoding.GetString (byte[],int,int) <0x00043>
I/mono (15065): at System.Text.UTF8Encoding.GetString (byte[],int,int) <0x0002b>
I/mono (15065): at System.Text.Encoding.GetString (byte[]) <0x00037>
I/mono (15065): at System.Net.WebClient.UploadString (System.Uri,string,string) <0x0007f>
I/mono (15065): at (wrapper remoting-invoke-with-check) System.Net.WebClient.UploadString (System.Uri,string,string) <0xffffffff>
이것은 분명히 버그입니다. 재현 가능한 테스트 케이스로 http://bugzilla.xamarin.com에 버그를 제출하십시오. –