Answered by:
GetMessageAsync exception or cann't return in C++

Question
-
I am running the example "SMS message send, receive, and SIM management sample" in the following link:
http://code.msdn.microsoft.com/windowsapps/Sms-SendReceive-fa02e55e
I authored device metadata(Note: not service metadata), and successfully get the Windows.Devices.Sms.SmsDevice object. And then system pop up a prompt to ask me if allow my metro app to visit the SmsDevice, I clicked "Allow". I successfully sent and received SMS by calling the SendMessageAsync() and SmsMessageReceivedEventHandler. However, when I tried to call GetMessageAsync() to read a message, it always not return. Then I tried in my app and lib, it also not works. Here is my usage:
void TestMBIMSms::DoReadMessage() {
auto getId = parser->ParseUInt(strReadIdText);
if ((getId != nullptr) && (getId->Value >= 1) && (getId->Value <= UINT32_MAX)
&& (getId->Value <= m_pSmsDevice->MessageStore->MaxMessages))
{
// Get the selected message from message store asynchronously.
create_task([this, getId] () {
return m_pSmsDevice->MessageStore->GetMessageAsync(static_cast<uint32> (getId->Value));
}).then([this] (ISmsMessage^ msg)
{
ISmsBinaryMessage^ binaryMsg = static_cast<ISmsBinaryMessage^> (msg);Besides, if I choose "Not allow" when system prompt me if app can visit the SmsDevice, then this code crashed and report the following exception, this is the same phenomenon as no SmsDevice is inserted:
First-chance exception at 0x7461277C in MBIMApp.exe: Microsoft C++ exception: Platform::COMException ^ at memory location 0x025FD83C. HRESULT:0x80070490
If there is a handler for this exception, the program may be safely continued.
Here is the crash stack:
KernelBase.dll!7461277c() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]
> msvcr110d.dll!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo) Line 152 C++
MBIMLib.dll!Concurrency::details::_ExceptionHolder::_RethrowUserException() Line 899 C++
MBIMLib.dll!Concurrency::details::_Task_impl_base::_Wait() Line 1404 C++
MBIMLib.dll!Concurrency::task<unsigned char>::get() Line 3028 C++
MBIMLib.dll!Concurrency::task<void>::get() Line 4010 C++
MBIMLib.dll!<lambda_a35c0976b2a432959a2bc7c5bbe80bb1>::operator()(Concurrency::task<void> catchErrors) Line 175 C++
MBIMLib.dll!std::_Callable_obj<<lambda_a35c0976b2a432959a2bc7c5bbe80bb1>,0>::_ApplyX<void,Concurrency::task<void> >(Concurrency::task<void> && _V0) Line 431 C++
MBIMLib.dll!std::_Func_impl<std::_Callable_obj<<lambda_a35c0976b2a432959a2bc7c5bbe80bb1>,0>,std::allocator<std::_Func_class<void,Concurrency::task<void>,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil> >,void,Concurrency::task<void>,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>::_Do_call(Concurrency::task<void> && _V0) Line 239 C++
MBIMLib.dll!std::_Func_class<void,Concurrency::task<void>,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>::operator()(Concurrency::task<void> _Vx0) Line 515 C++
MBIMLib.dll!<lambda_5f49ac87a52d4365c34eefcd31d0fa20>::operator()(Concurrency::task<void> t) Line 2185 C++
MBIMLib.dll!std::_Callable_obj<<lambda_5f49ac87a52d4365c34eefcd31d0fa20>,0>::_ApplyX<unsigned char,Concurrency::task<void> >(Concurrency::task<void> && _V0) Line 431 C++
MBIMLib.dll!std::_Func_impl<std::_Callable_obj<<lambda_5f49ac87a52d4365c34eefcd31d0fa20>,0>,std::allocator<std::_Func_class<unsigned char,Concurrency::task<void>,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil> >,unsigned char,Concurrency::task<void>,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>::_Do_call(Concurrency::task<void> && _V0) Line 239 C++
MBIMLib.dll!std::_Func_class<unsigned char,Concurrency::task<void>,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>::operator()(Concurrency::task<void> _Vx0) Line 515 C++
MBIMLib.dll!Concurrency::task<unsigned char>::_ContinuationTaskHandle<void,void,<lambda_a35c0976b2a432959a2bc7c5bbe80bb1>,std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorNoAsync>::_Continue(std::integral_constant<bool,1> __formal, Concurrency::details::_TypeSelectorNoAsync __formal) Line 3410 C++
MBIMLib.dll!Concurrency::task<unsigned char>::_ContinuationTaskHandle<void,void,<lambda_a35c0976b2a432959a2bc7c5bbe80bb1>,std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorNoAsync>::_Perform() Line 3318 C++
MBIMLib.dll!Concurrency::details::_PPLTaskHandle<unsigned char,Concurrency::task<unsigned char>::_ContinuationTaskHandle<void,void,<lambda_a35c0976b2a432959a2bc7c5bbe80bb1>,std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorNoAsync>,Concurrency::details::_ContinuationTaskHandleBase>::operator()() Line 1213 C++
MBIMLib.dll!Concurrency::details::_UnrealizedChore::_InvokeBridge<Concurrency::details::_PPLTaskHandle<unsigned char,Concurrency::task<unsigned char>::_ContinuationTaskHandle<void,void,<lambda_a35c0976b2a432959a2bc7c5bbe80bb1>,std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorNoAsync>,Concurrency::details::_ContinuationTaskHandleBase> >(Concurrency::details::_PPLTaskHandle<unsigned char,Concurrency::task<unsigned char>::_ContinuationTaskHandle<void,void,<lambda_a35c0976b2a432959a2bc7c5bbe80bb1>,std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorNoAsync>,Concurrency::details::_ContinuationTaskHandleBase> * _PChore) Line 4467 C++
msvcr110d.dll!Concurrency::details::_TaskCollection::_RunAndWait(Concurrency::details::_UnrealizedChore * pChore) Line 1607 C++
MBIMLib.dll!Concurrency::details::_AsyncTaskCollection::_ScheduleWithAutoInline(Concurrency::details::_UnrealizedChore * _PChore, Concurrency::details::_TaskInliningMode _InliningMode) Line 5472 C++
MBIMLib.dll!Concurrency::details::_Task_impl_base::_ScheduleTask(Concurrency::details::_UnrealizedChore * _PTaskHandle, Concurrency::details::_TaskInliningMode _InliningMode) Line 1564 C++
MBIMLib.dll!<lambda_6a579b9d48ea1c9b7e34f1d1e3f8e647>::operator()() Line 1671 C++
MBIMLib.dll!std::_Callable_obj<<lambda_6a579b9d48ea1c9b7e34f1d1e3f8e647>,0>::_ApplyX<void>() Line 431 C++
MBIMLib.dll!std::_Func_impl<std::_Callable_obj<<lambda_6a579b9d48ea1c9b7e34f1d1e3f8e647>,0>,std::allocator<std::_Func_class<void,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil> >,void,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>::_Do_call() Line 239 C++
MBIMLib.dll!std::_Func_class<void,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>::operator()() Line 514 C++
MBIMLib.dll!Concurrency::details::_ContextCallback::_Bridge(tagComCallData * _PParam) Line 572 C++
combase.dll!75af179f() Unknown
combase.dll!75b2f020() Unknown
rpcrt4.dll!7621855a() Unknown
rpcrt4.dll!762ca3ab() Unknown
msctf.dll!75bb2bc8() Unknown
KernelBase.dll!74625b25() Unknown
KernelBase.dll!74625c17() Unknown
KernelBase.dll!7460e2c1() Unknown
msctf.dll!75bbf54b() Unknown
msctf.dll!75bbf4af() Unknown
combase.dll!75b6e54d() Unknown
combase.dll!75b6b1cf() Unknown
combase.dll!75b6b0d5() Unknown
combase.dll!75a8030b() Unknown
user32.dll!76557443() Unknown
user32.dll!76557630() Unknown
user32.dll!765576b0() Unknown
user32.dll!7655763f() Unknown
user32.dll!765575be() Unknown
user32.dll!765576b0() Unknown
combase.dll!75ae189c() Unknown
combase.dll!75b723a8() Unknown
uxtheme.dll!737423f1() Unknown
user32.dll!76557443() Unknown
user32.dll!7655b593() Unknown
combase.dll!75abbd61() Unknown
combase.dll!75ae1850() Unknown
combase.dll!75ae2207() Unknown
Windows.UI.dll!53be11e2() Unknown
Windows.UI.dll!53be1290() Unknown
Windows.UI.Xaml.dll!53dadee2() Unknown
Windows.UI.Xaml.dll!53dadea1() Unknown
Windows.UI.Xaml.dll!53dade65() Unknown
ntdll.dll!76f276dc() Unknown
twinapi.dll!695fc9dd() Unknown
twinapi.dll!695fcab2() Unknown
twinapi.dll!695fc9f6() Unknown
SHCore.dll!76311ffd() Unknown
kernel32.dll!76681866() Unknown
ntdll.dll!76f468f1() Unknown
ntdll.dll!76f4689d() Unknown- Edited by steve xue Monday, September 24, 2012 5:51 AM bold the key words
Monday, September 24, 2012 5:47 AM
Answers
-
Steve,
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-MSFTModerator Tuesday, September 25, 2012 8:01 PM
Tuesday, September 25, 2012 8:01 PMModerator
All replies
-
My system is Win8 RTM professional Build 9200, my VS is VS2012 Ultimate which is the latest one on Microsoft website.
My problem is: GetMessageAsync() statement will returned immediately, but the "then" statement is never triggered, and the caller function never get to the end.create_task([this, getId] () {
return m_pSmsDevice->MessageStore->GetMessageAsync(static_cast<uint32> (getId->Value));
}).then([this] (ISmsMessage^ msg)- Edited by steve xue Monday, September 24, 2012 6:10 AM append the detail
Monday, September 24, 2012 5:52 AM -
Steve,
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-MSFTModerator Tuesday, September 25, 2012 8:01 PM
Tuesday, September 25, 2012 8:01 PMModerator