Unable to get default SMS device
-
Wednesday, November 09, 2011 9:32 AM
Hi,
when trying to call SmsDevice.GetDefault() I sometimes get an unexpected COM exception. Going back to documentation I read that the async operation should ship around this:
"Because the device might be busy, the operation executes asynchronously. The asynchronous operation object returns immediately."
I rewrote the code to access the device to use the async operation, but in no case the operation ever returned. Even worse, it looks as if the async operation doesn't ever execute. Here is my piece of code:
public async void ReadMessagesAsync() { try { System.Diagnostics.Debug.WriteLine("Getting device"); ISmsDevice device = await SmsDevice.GetDefaultAsync(); if (device == null) { System.Diagnostics.Debug.WriteLine("No device"); return; } System.Diagnostics.Debug.WriteLine("Reading messages"); IReadOnlyList<ISmsMessage> messages = await device.MessageStore.GetMessagesAsync(SmsMessageFilter.All); foreach (SmsBinaryMessage message in messages) { SmsTextMessage smsText = SmsTextMessage.FromBinaryMessage(message); System.Diagnostics.Debug.WriteLine(string.Format("From: {0}\r\n{1}", smsText.From, smsText.Body)); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } }
It does never continue after hitting:ISmsDevice device = await SmsDevice.GetDefaultAsync();
Can somebody help?
Best regards, Michael
- Edited by Michael Groeger Wednesday, November 09, 2011 10:00 AM
All Replies
-
Friday, November 11, 2011 5:48 PMModerator
Hi Michael,
What is the specific COM exception you are receiving from GetDefault()?
Do you see the same behavior with the "Sms Send/Receive" sample?
http://code.msdn.microsoft.com/windowsapps/Sms-SendReceive-fa02e55e
thanks
Frank
-
Thursday, April 05, 2012 5:18 PM
I'm getting exactly the same problems.
I get the COM exception anytime my 3G USB stick is missing (which is easily remedied by plugging it in)
Based on the sample code, I can call GetMessageAsync (Note no plural) and retrieve a message at a time, but not filtered to Unread/Read/etc, but if you call GetMessagesAsync (Note messageS) then it never returns. You will note that GetMessageS is not used in the sample
- Edited by AlSki.Net Thursday, April 05, 2012 5:19 PM
-
Wednesday, April 11, 2012 1:45 PM
I can able to send and receive SMS and retrieve the messages using the GetMessageAsync call by passing the message id.
But When I am trying to use GetMessagesAysnc, I am seeing an error.
var ReadAllMessages = smsdevice.MessageStore.GetMessagesAsync(SmsMessageFilter.All);
ReadAllMessages Errorcode "Message = "Number of parameters specified does not match the expected number."
Rest of the APIs are working, I am seeing problems only with GetMessagesAysnc function.
-
Wednesday, June 06, 2012 4:51 AMModerator
This functionality is only available to mobile operator apps and Metro style apps given privileged access by mobile network operators.
Best Wishes - Eric
- Marked As Answer by Eric Hanson-MSFTMicrosoft Employee, Moderator Wednesday, June 06, 2012 4:56 AM
-
Sunday, July 29, 2012 3:38 PM
Was this issue ever resolved? I have the same problem - getMessageAsync from returns "The parameter is incorrect" from a js app. (and I do have privileged access as I'm developing for a mobile network operator)
Mike
- Edited by MikeHowey Monday, July 30, 2012 10:19 AM
-
Wednesday, September 05, 2012 9:09 AM
i have authored the device metadata for my 3G datacard, and filled the SMS sample app information in the wizzard. After that, i debuged the SMS sample code, but when it hit the SmsDevice::GetDefaultAsync(), the exception HRESULT:0x80070005 always come out? does someone meet the same issue?
-
Monday, September 24, 2012 1:58 PMaccess denied. when i turn off the text message permission, it will show the 0X80070005 E_ACCESSDENIED error code
-
Tuesday, September 25, 2012 8:02 PMModerator
This functionality is only available to mobile operator apps and Windows Store apps given privileged access by mobile network operators, mobile broadband adapter IHV, or OEM. For more information, see Mobile Broadband: Windows Store device apps.
Best Wishes - Eric
- Marked As Answer by Eric Hanson-MSFTMicrosoft Employee, Moderator Tuesday, September 25, 2012 8:02 PM
-
Wednesday, October 31, 2012 8:29 AMThe computer must be set to the TEST MODE.


