I'm working with C++/WinRT for UWP. I am trying to create a file, but an exception is thrown at line 11 :
#include "pch.h"
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::Storage;
IAsyncAction createFile()
{
try
{
StorageFolder local{ ApplicationData::Current().LocalFolder() }; // line 11
StorageFolder folder = co_await local.CreateFolderAsync(L"myapp", CreationCollisionOption::OpenIfExists);
StorageFile file = co_await folder.CreateFileAsync(L"file", CreationCollisionOption::ReplaceExisting);
co_await FileIO::WriteTextAsync(file, L"wide chars here.");
}
catch (const winrt::hresult_error& ex)
{
}
}
int main()
{
init_apartment();
createFile();
}
The debugger doesn't shows me the error, because it crashes. The output says
onecoreuap\base\appmodel\statemanager\winrt\lib\windows.storage.applicationdatafactory.server.cpp(126)\Windows.Storage.ApplicationData.dll!00007FFE8A7A1202: (caller: 00007FFE8A799081) ReturnHr(1) tid(3ad8) 80073D54 The process has no package identity.
onecoreuap\base\appmodel\statemanager\winrt\lib\windows.storage.applicationdatafactory.server.cpp(74)\Windows.Storage.ApplicationData.dll!00007FFE8A7990A9: (caller: 00007FF733954323) ReturnHr(2) tid(3ad8) 80073D54 The process has no package identity.
Debug Error!
Program: D:\Developpement\CPP\test\x64\Debug\Tests.exe
abort() has been called
I found nothing about it on google, so what could this error mean, and how can I solve it ? Thanks