question

VijayadithyanN-4514 avatar image
0 Votes"
VijayadithyanN-4514 asked IgorTandetnik-1300 commented

What is the exception that this code is throwing and how to fix it?

the code is:

include "pch.h"


using namespace winrt;

using namespace Windows;
using namespace Windows::ApplicationModel::Core;
using namespace Windows::Foundation::Numerics;
using namespace Windows::UI;
using namespace Windows::UI::Core;
using namespace Windows::UI::Composition;

struct App : IFrameworkView
{
void Initialize(CoreApplicationView const& applicationView)
{

 }

 void Load(hstring const&)
 {
 }

 void Uninitialize()
 {
 }

 void Run()
 {
     CoreWindow window = CoreWindow::GetForCurrentThread();
     window.Activate();

     CoreDispatcher dispatcher = window.Dispatcher();
     dispatcher.ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit);
 }

 void SetWindow(CoreWindow const & window)
 {
        
 }

};

struct AppSource : IFrameworkViewSource
{
virtual IFrameworkView CreateView()
{
return App();
}
};

int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
{
CoreApplication::Run(AppSource());
}


It shows the window for a few seconds and then stops, throwing this window:
200081-image.png

How can i fix this?


windows-uwpc++
image.png (9.5 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CoreWindow::GetForCurrentThread() probably returns null, as your program never creates any windows.

1 Vote 1 ·

0 Answers