Adding a variable to a class causes a WinRT originate error. RRS feed

  • Question

  • I have a Clock class which causes my game to crash after I add the following line

        int FrameTimeTicks; // this line will cause the crash

    the error message reads:

    First-chance exception at 0x74B24598 (KernelBase.dll) in HH.exe: 0x40080201: WinRT originate error (parameters: 0x80000013, 0x0000001D, 0x02C3D5E0).
    First-chance exception at 0x74B24598 in HH.exe: Microsoft C++ exception: Platform::ObjectDisposedException ^ at memory location 0x02C3DA80. HRESULT:0x80000013 The object has been closed.
    WinRT information: The object has been closed.

    The program '[8200] HH.exe' has exited with code 0 (0x0).

    This is completely meaningless to me. It's a strange problem.

    Edit: When i step through the program, a breakpoint on the first line of MainPage() isn't reached before the exception is thrown. I can put a breakpoint in Clock constructor which looks like this:

    	//FrameTimeTicks = {};

    And it will be hit, when i step through from there, execution reaches the end of Clock(), goes to MainPage() open brace, but before it hits the first line I get "Source not available - Source information is missing from the debug information for this module ..."

    So has MainPage been disposed ?

    Here is the Clock.h file:

    #pragma once
    #include <Windows.h>
    #include <map>
    #include "Debug.h"
    using namespace std;
    using namespace Platform;
    using namespace Platform::Collections;
    class Clock
    	int64 MarkIn();
    	int64 MarkOut();
    	//int FrameTimeTicks;  // can't add these
    	//int FrameTimeMS = 0;
    	LARGE_INTEGER frequency = {};
    	LARGE_INTEGER pCountAppStart = {};
    	LARGE_INTEGER pCountStt = {};
    	LARGE_INTEGER pCountEnd = {};
    	//int frameTimeTicks; // can't add these either
    	//int frameTimeMS;

    Saturday, February 28, 2015 12:43 PM

All replies

  • So I think I have found the problem here, and I came to a fix by using Analyze > Run code analysis on solution. Something I've never used before. When i ran it, it gave me 3 issues, one of the issues was that I was using a byte* to pixel data after a failed call to


    I don't know why the call is failing as I call it immediately after creating the WriteableBitmap, and then later in ClearBitmap. Also, the call result never returns a failure. But, nevertheless, by checking for the HRESULT and returning NULL if it fails, then checking for NULL in the calling functions. The issue seems to have been resolved and I can add variables to my clock class.

    I guess something weird was happening with memory.

    Saturday, February 28, 2015 11:44 PM
  • This still isn't fixed, when i added another variable to my Clock class, the same problem arose, so whatever the issue is, it's being very secretive.
    Sunday, March 1, 2015 12:04 AM
  • Adding a variable to a class will not causes your application crash. Do you have a sample project for reproducing this issue? Or show us more code.

    HRESULT:0x80000013 The object has been closed.

    It seems that you reused some memory have beem released. I would to double check the processing logic.

    Monday, March 2, 2015 9:58 AM