[visual studio 2015] [C#] [windows10] [.NET Framework4.5.2]です。
現在bluetoothデータ発信デバイスから発信されるデータをPCで受信表示するアプリを作成しているのですが、サンプルを流用して作成してみたプログラムでエラーが発生し、解決出来ずに困っています。
エラー内容は下記です。
■エラー内容
**「型 'System.BadImageFormatException' の例外が mscorlib.dll で発生しましたが、ユーザー コード内ではハンドルされませんでした
追加情報:ファイルまたはアセンブリ 'System.Runtime.WindowsRuntime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'、またはその依存関係の 1 つが読み込めませんでした。参照アセンブリを実行用に読み込むことはできません。 参照アセンブリはリフレクション専用ローダー コンテキストでしか読み込めません。 (HRESULT からの例外:0x80131058)
この例外のハンドラーがある場合は、プログラムを安全に続行できます。」
**
■コード
C#
1public async void Form1_Load(object sender, EventArgs e) 2 { 3 //---------------------------------------------- 4 //RSSI受信処理初期設定 5 //---------------------------------------------- 6 this.watcher = new BluetoothLEAdvertisementWatcher(); 7 8 /*元々コメントアウトになってたところ*/ 9 //// CompanyIDとかDataでフィルタリングしたいとき 10 //var md = new BluetoothLEManufacturerData(); 11 //// company id 0xFFFF (多分これ https://www.bluetooth.com/specifications/assigned-numbers/company-Identifiers) 12 //md.CompanyId = 0xFFFF; 13 14 //// data 0x1234 15 //var w = new DataWriter(); 16 //w.WriteUInt16(0x1234); 17 //md.Data = w.DetachBuffer(); 18 //this.watcher.AdvertisementFilter.Advertisement.ManufacturerData.Add(md);*/ 19 20 // rssi >= -60のとき受信開始するっぽい 21 this.watcher.SignalStrengthFilter.InRangeThresholdInDBm = -60; 22 // rssi <= -65が2秒続いたら受信終わるっぽい 23 this.watcher.SignalStrengthFilter.OutOfRangeThresholdInDBm = -65; 24 this.watcher.SignalStrengthFilter.OutOfRangeTimeout = TimeSpan.FromMilliseconds(2000); 25 this.watcher.Received += this.Watcher_Received; 26 27 watcher.Start(); 28 29 await BLEInitialize();//BLEイニシャル処理やるとエラーになる 160726時点 30 } 31 32public async Task BLEInitialize() 33 { 34 DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(new Guid("0000180f-0000-1000-8000-00805f9b34fb")), new string[] { "System.Devices.ContainerId" }); 35 if (devices.Count == 0) 36 { 37 MessageBox.Show("Bluetooth デバイス が見つかりません"); 38 return; 39 } 40 GLOBAL.EcgList.Clear(); 41 DeviceTarget = 0; 42 for (int i = 0; i < devices.Count; i++) 43 { 44 if (devices[i].Name == ECGID) 45 { 46 DeviceTarget = i; 47 } 48 GLOBAL.EcgList.Add(devices[i]); 49 } 50 ECGID = devices[DeviceTarget].Name; 51 await BLEGatt.Instance.ConnectBluetooth(true, ECGID); 52 Device = devices[DeviceTarget]; 53 }
■問題点の詳細
・await BLEInitialize()を実行時にエラーが出る。await BLEInitialize()の中のどこかでエラーが出るのではなく、await BLEInitialize()を実行した時に上記のエラーが出る。
■特にわからない点
・エラーの追加情報で出ている「'System.Runtime.WindowsRuntime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'」が理解出来ない。どこを確認して何を修正したらいいのかわからない。
何か解決の糸口になりそうなことがあれば教えて頂けると幸いです。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。