2016-09-25 2 views
1

안녕하세요, Android에서 디버깅 할 때 Azure 모바일 서비스 오프라인 저장소를 사용할 때이 예외가 발생합니다. 비록 창문을 사용할 때 잘 작동합니다.Xamrin forms System.TypeInitializationException

수도 : System.TypeInitializationException : 예외가 발생했습니다 'OrchardApp.StaffManager'의 형식 이니셜 여기

단지 tod0list 예

static StaffManager defaultInstance = new StaffManager(); 
    MobileServiceClient client; 

    IMobileServiceSyncTable<Staff> staffTable; 

    private StaffManager() 
    { 
     client = new MobileServiceClient(Constants.ApplicationURL); 

      var store = new MobileServiceSQLiteStore("localstore1.db"); 
      store.DefineTable<Staff>(); 

      this.client.SyncContext.InitializeAsync(store); 

      this.staffTable = client.GetSyncTable<Staff>(); 

    } 

본에 기초하여 상기 코드 것은 예외이다.

09-26 11 : 05 : 48.991 D/Mono (1684) : Dll 가져 오기를 시도하는 포트 : '/system/lib/liblog.so'. 09-26 11 : 05 : 48.991 D/Mono (1684) : DllImport로드 라이브러리 '/system/lib/liblog.so'. 09-26 11 : 05 : 48.991 D/Mono (1684) : '/system/lib/liblog.so'에서 검색하는 DllImport ('/system/lib/liblog.so'). 09-26 11 : 05 : 48.991 D/Mono (1684) : '__android_log_print'를 검색 중입니다. 09-26 11 : 05 : 48.991 D/Mono (1684) : '__android_log_print'검색. 09-26 11 : 05 : 48.991 D/Mono (1684) : '__android_log_print'로 발견되었습니다. 09/6 11 : 05 : 48.991 I/MonoDroid (1684) : UNHANDLED 예외 : 09-26 11 : 05 : 48.991 I/MonoDroid (1684) : System.TypeInitializationException : 'OrchardApp.StaffManager'의 형식 이니셜 라이저에서 예외. ---> Microsoft.WindowsAzure.MobileServices.SQLiteStore.SQLiteException : SQLite 명령을 실행하는 중 오류가 발생했습니다 : '데이터베이스 파일을 열 수 없습니다'. 09-26 11 : 05 : 48.991 I/MonoDroid (1684) : Microsoft.WindowsAzure.MobileServices.SQLiteStore.SQLitePCLRawHelpers.VerifySQLiteResponse (Int32 결과, Int32 expectedResult, SQLitePCL.sqlite3 db) [0x00024] : 0 09-26 11 : 05 : 48.991 I/MonoDroid (1684) : Microsoft.WindowsAzure.MobileServices.SQLiteStore.SQLitePCLRawHelpers.GetSqliteConnection (System.String 파일 이름) [0x0000d] in : 0 09-26 11 : 05 : 48.991 I/MonoDroid (1684) : Microsoft.WindowsAzure.MobileServices.SQLiteStore.MobileServiceSQLiteStore..ctor (System.String fileName) [0x00039] in : 0 09-26 11 : 05 : 48.991 I/MonoDroid (1684) : OrchardApp.StaffManager..ctor에서 OrchardApp \ OrchardApp \ Services \ StaffManager.cs : 27 09-26 11 : 05 : 48.991 I/MonoDroid (1684) : OrchardApp.StaffManager..cctor()에서 [0x0001e] 0x00000] C : \ OPAC \ OrchardApp \ OrchardApp \ OrchardApp \ Services \ StaffManager.cs : 16 09-26 11 : 05 : 48.991 I/MonoDroid (1684) : --- 내부 예외 스택 추적 끝 --- 09-26 11 : 05 : 48.991 I/MonoDroid (1684) : OrchardApp.TodoList..ctor() [0x0000f] C : \ OPAC \ OrchardApp \ OrchardApp \ OrchardApp \ Views \ TodoList.xaml.cs : 18 09-26 11 : 05 : 48.991 I/MonoDroid (1684) : at OrchardApp \ OrchardApp \ OrchardApp \ OrchardApp \ Views \ HomePage.xaml.cs의 d.MoveNext() [0x0000f] 26 < 26 : MonoDroid (1684) : --- 예외가 throw 된 이전 위치에서 스택 추적 끝 --- 09-26 11 : 05 : 48.991 I/MonoDroid (1684) : System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [0x0000c] in/Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/예외 rvicescommon.cs : 143 09-26 11 : 05 : 48.995/User/builder/data/lanes /에있는 System.Runtime.CompilerServices.AsyncMethodBuilderCore.m__0 (System.Object 상태) [0x00000]의 I/MonoDroid (1684) 3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs : 1018 09-26 11 : 05 : 48.995 I/MonoDroid (1684) : Android.App.SyncContext + c__AnonStorey0에 있습니다. <> m__0() [0x00000] /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18 09-26 11:05 : 48.995 I/MonoDroid (1684) : Java.Lang.Thread + RunnableImplementor.Run() [/0.00000b] /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/ Java.Lang/Thread.cs : 36 09-26 11:05:48.995 I/MonoDroid (1684)에서 Java.Lang.IRunnableInvoker.n_Run (을 IntPtr의 JNIEnv, native__this을 IntPtr) 0x00009]에 /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/ 플랫폼/안드로이드 23/SRC/생성/Java.Lang.IRunnable.cs : 81 11월 9일에서 26일까지 : 05 : 48.995 I/MonoDroid (1684)에서 (래퍼 동적 법)으로 System.Object : 578fa2b5-486e- -424F-9b2b bb0dcaf1a772 (INTPTR, INTPTR) 11월 9일에서 26일까지 : 05 : 같이 DllImport에서 검색이 :/모노 (1684)는 49.003 D '__Internal'('(NULL)'). 09-26 11 : 05 : 49.003 D/Mono (1684) : 'java_interop_jnienv_throw'를 검색 중입니다. 09-26 11 : 05 : 49.003 D/Mono (1684) : 프로빙 'java_interop_jnienv_throw'. 09-26 11 : 05 : 49.003 D/Mono (1684) : 'java_interop_jnienv_throw'로 발견됨. 처리되지 않은 예외가 발생했습니다. 토마스 Hagstrom에서

+0

답변을 얻으려면 예외 (메시지 및 발생 위치)를 지정해야합니다. 다음은 Xamarin 디버깅에 대한 몇 가지 팁입니다. http://xamariniac.hlinteractive.se/index.php/2016/09/22/debugging-xamarin-and-cross-platform-exceptions/ –

+0

안녕하세요 예외 세부 정보를 추가했습니다. –

+1

일부 Azure 모바일 서비스를 (그들의 경우 2.1.1로) 낮추라고 제안했다. https://forums.xamarin.com/discussion/78936/microsoft-azure-mobile-client-sqlitestore-upgraded-to-3-0-get-error-unable-to-open-database-file –

답변

0

비슷한 문제는 내가 this 해결

PCL 프로젝트 App.cs

 public static string Path = "MyLocalStore.db"; 

안드로이드 프로젝트 MainActivity.cs Nel 보낸 metodo에서 OnCreate

 //Call this in each platform before intializing your Mobile Client 
     SQLitePCL.Batteries.Init(); 

     App.Path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), App.Path); 

     if (!File.Exists(App.Path)) 
     { 
      File.Create(App.Path).Dispose(); 
     } 
으로 해결 한

마지막으로

 var store = new MobileServiceSQLiteStore(App.Path); 
관련 문제