FObjectFinder Breakout

When trying to load in a Data Table within my UUserWidget class the program breaks out within the TObjectFinder function, see image below

323164-capture.png

I have tried calling TObjectFinder outside my NativeConstruct.

#include "ShopWindow_UI.h"

static ConstructorHelpers::FObjectFinder<UDataTable> dataTable(TEXT("DataTable'/Game/Inventory/Items/DataTable.DataTable'")); 

void UShopWindow_UI::NativeConstruct()
{
	if (dataTable.Succeeded())
	{
		itemDataTable = dataTable.Object;
	}
}

And inside NativeConstruct.

#include "ShopWindow_UI.h"

void UShopWindow_UI::NativeConstruct()
{
	static ConstructorHelpers::FObjectFinder<UDataTable> dataTable(TEXT("DataTable'/Game/Inventory/Items/DataTable.DataTable'")); 
	
	if (dataTable.Succeeded())
	{
		itemDataTable = dataTable.Object;
	}
}

I’m not sure what is causing the issues as I have looked at similar uses of the TObjectFinder online and mine matches their use. It could most likely be a simple misunderstanding that I’m not noticing.

Thanks

Dear valued Unreal Engine user,

From a first glance this looks as though NativeConstruct is not the correct constructor. You might need to place it inside a C++ constructor.

For example:

ShopWindow_UI.h

...
public:
    UShopWindow_UI(const FObjectInitializer& ObjectInitializer);
...

and ShopWindow_UI.cpp

UShopWindow_UI::UShopWindow_UI(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}

Thank you for your continued support,

Anthony