質問編集履歴

3

現時点でのアプローチ追加

2017/08/27 14:02

投稿

super1234
super1234

スコア52

test CHANGED
File without changes
test CHANGED
@@ -617,3 +617,23 @@
617
617
  }
618
618
 
619
619
  }
620
+
621
+
622
+
623
+
624
+
625
+ その後考えたのですが、
626
+
627
+
628
+
629
+ http://ticktack.hatenablog.jp/entry/2017/02/06/234012
630
+
631
+ ![イメージ説明](40388a22a65d6c5aa38ccb386841a59c.png)
632
+
633
+
634
+
635
+ 非推奨なのでエラーの直接的な原因なのかは定かではないのですが、
636
+
637
+ この入れ方でもしかしたらうまくいくかもしれないと考えてはいますが、breakの前に数字を置いてもうまくいかずといった状況が今です。
638
+
639
+ 他のアプローチなどアドバイスありましたらよろしくお願いいたします。

2

詳細コード追加

2017/08/27 14:02

投稿

super1234
super1234

スコア52

test CHANGED
File without changes
test CHANGED
@@ -32,21 +32,555 @@
32
32
 
33
33
  ーーーーーーーーーーーーーーーーーーーー
34
34
 
35
+ ![イメージ説明](e88e734f250cf6e5449e5e5dbfec7c10.png)
36
+
37
+
38
+
39
+
40
+
41
+ ーーーーーーーーーーーーーーーーーーーー
42
+
43
+ デバッグ中の出力は以下です。
44
+
45
+ ーーーーーーーーーーーーーーーーーー
46
+
47
+ 08-25 15:03:04.285 D/Mono (32120): Image addref System.Runtime.Serialization[0x9c94b040] -> System.Runtime.Serialization.dll[0x9c92d600]: 2
48
+
49
+ 08-25 15:03:04.285 D/Mono (32120): Prepared to set up assembly 'System.Runtime.Serialization' (System.Runtime.Serialization.dll)
50
+
51
+ 08-25 15:03:04.286 D/Mono (32120): Assembly System.Runtime.Serialization[0x9c94b040] added to domain RootDomain, ref_count=1
52
+
53
+ 08-25 15:03:04.289 D/Mono (32120): AOT: image 'System.Runtime.Serialization.dll.so' not found: dlopen failed: library "/data/app/SampleApp.Android-1/lib/arm/libaot-System.Runtime.Serialization.dll.so" not found
54
+
55
+ 08-25 15:03:04.291 D/Mono (32120): AOT: image '/usr/local/lib/mono/aot-cache/arm/System.Runtime.Serialization.dll.so' not found: dlopen failed: library "/data/app/SampleApp.Android-1/lib/arm/libaot-System.Runtime.Serialization.dll.so" not found
56
+
57
+ 08-25 15:03:04.291 D/Mono (32120): Config attempting to parse: 'System.Runtime.Serialization.dll.config'.
58
+
59
+ 08-25 15:03:04.291 D/Mono (32120): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Runtime.Serialization/System.Runtime.Serialization.config'.
60
+
61
+ 08-25 15:03:04.291 D/Mono (32120): Assembly Ref addref Mono.Android[0xaf37be80] -> System.Runtime.Serialization[0x9c94b040]: 2
62
+
63
+ 08-25 15:03:04.294 D/Mono (32120): Assembly Ref addref System.Runtime.Serialization[0x9c94b040] -> mscorlib[0xaf37b4c0]: 37
64
+
65
+ ーーーーーーーーーーーーーーーーーー
66
+
67
+
68
+
69
+
70
+
71
+ ハンドルされていないエラーとしてデバッグを始めた直後にデバッグが止まってしまい、
72
+
73
+ googleなどで調べても解決できない状態です。書籍問い合わせもしていますが、いっこうにお返事なく
74
+
75
+ 何かアドバイス頂けないでしょうか。
76
+
77
+ よろしくお願いいたします。
78
+
79
+
80
+
81
+
82
+
83
+ ご指摘アドバイス頂きましてPCL側なども記載します。
84
+
85
+
86
+
87
+ ●全体的な構成
88
+
89
+
90
+
91
+ 下記のようにPCLプロジェクトを作成
92
+
93
+ ![イ![イメージ説明](1038664894a00eabbc8a9ab181863324.png)(f4755f61160ee8cac59a3204fcf6cd25.png)
94
+
95
+
96
+
97
+ そのPCLを参照しているSampleAppプロジェクトを作成
98
+
99
+ ![イメージ説明](2ce036c14d17c5bb776b8d5715b42475.png)
100
+
101
+
102
+
103
+ ●主要なコード
104
+
105
+
106
+
107
+
108
+
109
+ PCL側
110
+
111
+ ・SamplePCL.cs
112
+
113
+
114
+
115
+ namespace SamplePCL
116
+
117
+ {
118
+
119
+ public class SamplePCL : ContentPage
120
+
121
+ {
122
+
123
+ public SamplePCL()
124
+
125
+ {
126
+
127
+ var button = new Button
128
+
129
+ {
130
+
131
+ Text = "Click Me!",
132
+
133
+ VerticalOptions = LayoutOptions.CenterAndExpand,
134
+
135
+ HorizontalOptions = LayoutOptions.CenterAndExpand,
136
+
137
+ };
138
+
139
+
140
+
141
+ int clicked = 0;
142
+
143
+ button.Clicked += (s, e) => button.Text = "Clicked: " + clicked++;
144
+
145
+
146
+
147
+ Content = button;
148
+
149
+ }
150
+
151
+ }
152
+
153
+ }
154
+
155
+
156
+
157
+ ・SqliteControl.cs
158
+
159
+
160
+
161
+ using System.Collections.Generic;
162
+
163
+ using SQLite.Net;
164
+
165
+ using Xamarin.Forms;
166
+
167
+
168
+
169
+ namespace SampleApp
170
+
171
+ {
172
+
173
+ public class SqliteControl
174
+
175
+ {
176
+
177
+ static readonly object wObject = new object();
178
+
179
+ readonly SQLiteConnection wSQLiteConnection;
180
+
181
+ // SQLiteデータベースに接続
182
+
183
+ public SqliteControl()
184
+
185
+ {
186
+
187
+ //接続
188
+
189
+ wSQLiteConnection =
190
+
191
+ DependencyService.Get<ISqliteInterface>().GetConnection();
192
+
193
+ // データ管理用テーブル作成
194
+
195
+ wSQLiteConnection.CreateTable<SqliteItem>();
196
+
197
+
198
+
199
+ }
200
+
201
+ // データの取得
202
+
203
+ public IEnumerable<SqliteItem> GetItems()
204
+
205
+ {
206
+
207
+ lock (wObject)
208
+
209
+ {
210
+
211
+ return wSQLiteConnection.Table<SqliteItem>();
212
+
213
+ }
214
+
215
+ }
216
+
217
+ // データの登録
218
+
219
+ public void InsertItem(SqliteItem item)
220
+
221
+ {
222
+
223
+ lock (wObject)
224
+
225
+ {
226
+
227
+ wSQLiteConnection.Insert(item);
228
+
229
+ }
230
+
231
+ }
232
+
233
+ // データの削除
234
+
235
+ public void DeleteItem(SqliteItem item)
236
+
237
+ {
238
+
239
+ lock (wObject)
240
+
241
+ {
242
+
243
+ wSQLiteConnection.Delete(item);
244
+
245
+ }
246
+
247
+ }
248
+
249
+ }
250
+
251
+ }
252
+
253
+
254
+
255
+ ・SqliteInterface.cs
256
+
257
+
258
+
259
+ using SQLite.Net;
260
+
261
+
262
+
263
+ namespace SampleApp
264
+
265
+ {
266
+
267
+
268
+
269
+ public interface ISqliteInterface
270
+
271
+ {
272
+
273
+
274
+
275
+ SQLiteConnection GetConnection();
276
+
277
+ }
278
+
279
+ }
280
+
281
+
282
+
283
+ ・SqliteItem.cs
284
+
285
+
286
+
287
+ using SQLite.Net.Attributes;
288
+
289
+
290
+
291
+ namespace SampleApp
292
+
293
+ {
294
+
295
+ public class SqliteItem
296
+
297
+ {
298
+
299
+ [PrimaryKey, AutoIncrement]
300
+
301
+ public int ID { get; set; }
302
+
303
+ public string Text { get; set; }
304
+
305
+ public DateTime InsertDate { get; set; }
306
+
307
+ }
308
+
309
+ }
310
+
311
+
312
+
313
+ 画面プロジェクト側
314
+
315
+
316
+
317
+ ・AppSaml.cs
318
+
319
+
320
+
321
+ using Xamarin.Forms;
322
+
323
+
324
+
325
+ namespace SampleApp
326
+
327
+ {
328
+
329
+ public partial class App : Application
330
+
331
+ {
332
+
333
+ public App()
334
+
335
+ {
336
+
337
+ InitializeComponent();
338
+
339
+
340
+
341
+ MainPage = new SampleApp.SamplePage();
342
+
343
+ }
344
+
345
+
346
+
347
+ }
348
+
349
+
350
+
351
+ ・SamplePage.cs
352
+
353
+
354
+
35
355
  using System;
36
356
 
37
-
38
-
39
- using Android.App;
40
-
41
- using Android.Content.PM;
42
-
43
- using Android.Runtime;
44
-
45
- using Android.Views;
46
-
47
- using Android.Widget;
48
-
49
- using Android.OS;
357
+ using Xamarin.Forms;
358
+
359
+ using SQLite.Net;
360
+
361
+ using SamplePCL;
362
+
363
+
364
+
365
+ namespace SampleApp
366
+
367
+ {
368
+
369
+ class SamplePage : ContentPage
370
+
371
+ {
372
+
373
+ readonly SqliteControl wSqliteControl = new SqliteControl();
374
+
375
+ public SamplePage()
376
+
377
+ {
378
+
379
+ // データ表示用リスト
380
+
381
+ var wListView = new ListView
382
+
383
+ {
384
+
385
+ ItemsSource = wSqliteControl.GetItems(),
386
+
387
+ ItemTemplate = new DataTemplate(typeof(TextCell))
388
+
389
+ };
390
+
391
+ wListView.ItemTemplate.SetBinding(TextCell.TextProperty, "Text");
392
+
393
+ wListView.ItemTemplate.SetBinding(TextCell.DetailColorProperty, new Binding("InsertDate",
394
+
395
+ stringFormat: "{0:yyy/MM/dd hh:mm}"));
396
+
397
+ // データタップ時の処理
398
+
399
+ wListView.ItemTapped += async (s, a) =>
400
+
401
+ {
402
+
403
+ var wItem = (SqliteItem)a.Item;
404
+
405
+ if (await DisplayAlert("削除しますか", wItem.Text, "はい", "いいえ"))
406
+
407
+ {
408
+
409
+ // データの削除
410
+
411
+ wSqliteControl.DeleteItem(wItem);
412
+
413
+ // データの再取得
414
+
415
+ wListView.ItemsSource = wSqliteControl.GetItems();
416
+
417
+ }
418
+
419
+ };
420
+
421
+ // ラベル1
422
+
423
+ var wLabel1 = new Label
424
+
425
+ {
426
+
427
+ Text = "サンプルアプリ (データ登録・削除)",
428
+
429
+ BackgroundColor = Color.Navy,
430
+
431
+ TextColor = Color.White,
432
+
433
+ WidthRequest = 600
434
+
435
+ };
436
+
437
+ // ラベル2
438
+
439
+ var wLabel2 = new Label
440
+
441
+ {
442
+
443
+ Text = "登録データ一覧",
444
+
445
+ BackgroundColor = Color.Gray,
446
+
447
+ TextColor = Color.White,
448
+
449
+ WidthRequest = 300
450
+
451
+ };
452
+
453
+ // データ入力
454
+
455
+ var wEntry = new Entry
456
+
457
+ {
458
+
459
+ HorizontalOptions = LayoutOptions.FillAndExpand
460
+
461
+ };
462
+
463
+ // 登録ボタン
464
+
465
+ var wButtonIns = new Button
466
+
467
+ {
468
+
469
+ Text = "登録",
470
+
471
+ TextColor = Color.White,
472
+
473
+ WidthRequest = 60
474
+
475
+ };
476
+
477
+ // 登録ボタンの押下時の処理
478
+
479
+ wButtonIns.Clicked += (s, a) =>
480
+
481
+ {
482
+
483
+ if (!String.IsNullOrEmpty(wEntry.Text))
484
+
485
+ {
486
+
487
+ // 登録データ設定
488
+
489
+ var item = new SqliteItem
490
+
491
+ {
492
+
493
+ Text = wEntry.Text,
494
+
495
+ InsertDate = DateTime.Now
496
+
497
+ };
498
+
499
+ // データの登録
500
+
501
+ wSqliteControl.InsertItem(item);
502
+
503
+ // データの再取得
504
+
505
+ wListView.ItemsSource = wSqliteControl.GetItems();
506
+
507
+ // 入力データ初期化
508
+
509
+ wEntry.Text = "";
510
+
511
+ }
512
+
513
+ };
514
+
515
+ // 画面
516
+
517
+ Content = new StackLayout
518
+
519
+ {
520
+
521
+ Padding = new Thickness
522
+
523
+ (
524
+
525
+ 0,
526
+
527
+ Device.OnPlatform(20, 0, 0),
528
+
529
+ 0,
530
+
531
+ 0
532
+
533
+ ),
534
+
535
+ Children =
536
+
537
+ {
538
+
539
+ wLabel1,
540
+
541
+ new StackLayout
542
+
543
+ {
544
+
545
+ BackgroundColor = Color.Green,
546
+
547
+ Padding = 5,
548
+
549
+ Orientation = StackOrientation.Horizontal,
550
+
551
+ Children =
552
+
553
+ {
554
+
555
+ wEntry, wButtonIns
556
+
557
+ }
558
+
559
+ },
560
+
561
+ wLabel2,
562
+
563
+ wListView
564
+
565
+ }
566
+
567
+ };
568
+
569
+ }
570
+
571
+ }
572
+
573
+ }
574
+
575
+
576
+
577
+
578
+
579
+ 画面プロジェクトのAndroid側
580
+
581
+
582
+
583
+ MainActivity.cs
50
584
 
51
585
 
52
586
 
@@ -83,45 +617,3 @@
83
617
  }
84
618
 
85
619
  }
86
-
87
-
88
-
89
- ーーーーーーーーーーーーーーーーーーーー
90
-
91
- デバッグ中の出力は以下です。
92
-
93
- ーーーーーーーーーーーーーーーーーー
94
-
95
- 08-25 15:03:04.285 D/Mono (32120): Image addref System.Runtime.Serialization[0x9c94b040] -> System.Runtime.Serialization.dll[0x9c92d600]: 2
96
-
97
- 08-25 15:03:04.285 D/Mono (32120): Prepared to set up assembly 'System.Runtime.Serialization' (System.Runtime.Serialization.dll)
98
-
99
- 08-25 15:03:04.286 D/Mono (32120): Assembly System.Runtime.Serialization[0x9c94b040] added to domain RootDomain, ref_count=1
100
-
101
- 08-25 15:03:04.289 D/Mono (32120): AOT: image 'System.Runtime.Serialization.dll.so' not found: dlopen failed: library "/data/app/SampleApp.Android-1/lib/arm/libaot-System.Runtime.Serialization.dll.so" not found
102
-
103
- 08-25 15:03:04.291 D/Mono (32120): AOT: image '/usr/local/lib/mono/aot-cache/arm/System.Runtime.Serialization.dll.so' not found: dlopen failed: library "/data/app/SampleApp.Android-1/lib/arm/libaot-System.Runtime.Serialization.dll.so" not found
104
-
105
- 08-25 15:03:04.291 D/Mono (32120): Config attempting to parse: 'System.Runtime.Serialization.dll.config'.
106
-
107
- 08-25 15:03:04.291 D/Mono (32120): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Runtime.Serialization/System.Runtime.Serialization.config'.
108
-
109
- 08-25 15:03:04.291 D/Mono (32120): Assembly Ref addref Mono.Android[0xaf37be80] -> System.Runtime.Serialization[0x9c94b040]: 2
110
-
111
- 08-25 15:03:04.294 D/Mono (32120): Assembly Ref addref System.Runtime.Serialization[0x9c94b040] -> mscorlib[0xaf37b4c0]: 37
112
-
113
- ーーーーーーーーーーーーーーーーーー
114
-
115
- ![イメージ説明](e88e734f250cf6e5449e5e5dbfec7c10.png)
116
-
117
-
118
-
119
-
120
-
121
- ハンドルされていないエラーとしてデバッグを始めた直後にデバッグが止まってしまい、
122
-
123
- googleなどで調べても解決できない状態です。書籍問い合わせもしていますが、いっこうにお返事なく
124
-
125
- 何かアドバイス頂けないでしょうか。
126
-
127
- よろしくお願いいたします。

1

デバッグエラー中の画像添付

2017/08/27 10:55

投稿

super1234
super1234

スコア52

test CHANGED
File without changes
test CHANGED
@@ -112,6 +112,10 @@
112
112
 
113
113
  ーーーーーーーーーーーーーーーーーー
114
114
 
115
+ ![イメージ説明](e88e734f250cf6e5449e5e5dbfec7c10.png)
116
+
117
+
118
+
115
119
 
116
120
 
117
121
  ハンドルされていないエラーとしてデバッグを始めた直後にデバッグが止まってしまい、