Editor crash when using Online Subsystem


Here is my code


class NETWORKDEMO_API AUNWGameInstance : public AGameSession

TSharedPtr MySessionSettings;
FOnCreateSessionCompleteDelegate OnCreateSessionCompleteDelegate;
FDelegateHandle OnCreateSessionCompleteDelegateHandle;


		MySessionSettings = MakeShareable(new FOnlineSessionSettings());
		OnCreateSessionCompleteDelegate = FOnCreateSessionCompleteDelegate::CreateUObject(this, &AUNWGameInstance::OnCreateSessionComplete);

When i run my program,editor will crash with the error,Access violation - code c0000005 (first/second chance not available)
It`s strange,i have declare MySessionSettings and OnCreateSessionCompleteDelegate in my header file
So,what do i miss?Does anyone have a solution for my problem?
Thank you!

I have solved this problem,when getting the GameSession,we should use const like the code below

AUNWGameInstance* ANetWorkActor::GetGameSession() const
	UWorld* const World = GetWorld();
	if (World)
		AGameModeBase* const Game = World->GetAuthGameMode();
		if (Game)
			return Cast<AUNWGameInstance>(Game->GameSession);

	return nullptr;