locked
WriteTextAsync crashes Modern App

    Question

  • Hello,

    I have the following code (run from application activated event handler, using presumably UI dispatcher). CreateFileAsync creates the text file but WriteTextAsync crashes. Is this a bug in WinRT libraries?

    First-chance exception at 0x00007FFEF60943C8 (KernelBase.dll) in MyApp.exe: 0x40080201: WinRT originate error (parameters: 0x000000008000000B, 0x0000000000000040, 0x000000DE39F6F1E0).

    auto t = task<StorageFile^>(KnownFolders::DocumentsLibrary->CreateFileAsync("myfile.txt", CreationCollisionOption::OpenIfExists)).then([&](StorageFile^ file) { FileIO::WriteTextAsync(file, "Hello"); return file; });

    Tuesday, July 15, 2014 8:32 PM

All replies

  • Hi,

    I cannot reproduce your problem. When I create a file and then use WriteTextAsync method write text to the file. Everything is very well. And I do not know what you meaning about"run from application activated event handler, using presumably UI dispatcher",Please upload a reproduce sample to OneDrive so that we can test it.

    I create a project like below:

    MainPage::MainPage()
    {
    	InitializeComponent();
    	auto t = create_task(KnownFolders::DocumentsLibrary->CreateFileAsync("myfile.txt", CreationCollisionOption::OpenIfExists)).then([&](StorageFile^ file)
    	{
    		FileIO::WriteTextAsync(file, "Hello");
    
    		return file;
    	});
    
    
    }
    
    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    Wednesday, July 16, 2014 2:27 AM