我一直在尝试开发我的Windows Phone 8应用程序来访问配对的蓝牙设备(打印机)并发送一些打印数据.
我正在开发Windows 8 64位并使用VS2012 Express.由于仿真器不支持蓝牙,我一直在将该版本上传到诺基亚Lumia 820进行测试.
我使用了以下两个站点作为参考:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207007(v=vs.105).aspx
http://www.geekchamp.com/articles/getting-started-with-bluetooth-in-windows-phone-8
应用程序找到配对设备并通过Debug命令输出打印机名称.
代码一直运行到这一点:
await socket.ConnectAsync(selectedDevice.HostName, "1");
Run Code Online (Sandbox Code Playgroud)
然后它打破了以下异常:
********** EXCEPTION OCCURED **********
Data: System.Collections.ListDictionaryInternal
InnerException:
Message: An attempt was made to access a socket in a way forbidden by its access permissions. (Exception from HRESULT: 0x8007271D)
StackTrace: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at mobility.PrinterSettings.<AppToDevice>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__0(Object state)
********** EXCEPTION OCCURED **********
Run Code Online (Sandbox Code Playgroud)
如果在socket.ConnectAsync之前删除"await"(selectedDevice.HostName,"1"); 然后代码将继续没有任何错误,但没有蓝牙连接?
我已经尝试了在教程中说明的1到30之间的每个数字,并且我还确保在WMAppManifest.xml中启用了ID_CAP_NETWORKING.
请问有人有什么想法吗? …