# Access violation - Project Crashes On load

**URL:** <https://forums.unrealengine.com/t/access-violation-project-crashes-on-load/311436>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 17, 2015, 8:49pm UTC](https://forums.unrealengine.com/t/access-violation-project-crashes-on-load/311436 "2015-03-17T20:49:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quaso](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Quaso](https://forums.unrealengine.com/u/Quaso)\
**Post date:** [March 17, 2015, 8:49pm UTC](https://forums.unrealengine.com/t/access-violation-project-crashes-on-load/311436/1 "2015-03-17T20:49:58Z")

</div>

Hey All.

My project has been working without any problems till that i decided to restart unreal engine.

Now i cant even open my project. 😕

Any Suggestions? 🙂

* * *

Access violation - code c0000005 (first/second chance not available)

UE4Editor\_Engine!UEngine::AddOnScreenDebugMessage() + 4 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\unrealengine.cpp:6141]  
UE4Editor\_Prison\_4522!AFPSGameMode::AFPSGameMode() + 287 bytes [d:\projects\unreal\prison\source\prison\fpsgamemode.cpp:16]  
UE4Editor\_CoreUObject!UClass::CreateDefaultObject() + 435 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\class.cpp:2506]  
UE4Editor\_CoreUObject!UObjectLoadAllCompiledInDefaultProperties() + 805 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:739]  
UE4Editor\_CoreUObject!ProcessNewlyLoadedUObjects() + 146 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:815]  
UE4Editor\_CoreUObject!TBaseStaticDelegateInstance::ExecuteIfSafe() + 7 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\core\public\delegates\delegateinstancesimpl\_variadics.inl:921]  
UE4Editor\_Core!TBaseMulticastDelegate::Broadcast() + 149 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\core\public\delegates\delegatesignatureimpl\_variadics.inl:1030]  
UE4Editor\_Core!FModuleManager::LoadModuleWithFailureReason() + 2194 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\core\private\modules\modulemanager.cpp:359]  
UE4Editor\_Projects!FModuleDescriptor::LoadModulesForPhase() + 784 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\projects\private\moduledescriptor.cpp:350]  
UE4Editor\_Projects!FProjectManager::LoadModulesForProject() + 581 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\projects\private\projectmanager.cpp:53]  
UE4Editor!FEngineLoop::LoadStartupModules() + 705 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launchengineloop.cpp:1863]  
UE4Editor!FEngineLoop::PreInit() + 11141 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launchengineloop.cpp:1400]  
UE4Editor!GuardedMain() + 251 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launch.cpp:110]  
UE4Editor!GuardedMainWrapper() + 26 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]  
UE4Editor!WinMain() + 249 bytes [d:\buildfarm\buildmachine\_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]  
UE4Editor!\_\_tmainCRTStartup() + 329 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]

CODE:

FPSGameMode.h

```
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "GameFramework/GameMode.h"
#include "FPSGameMode.generated.h"

/**
 * 
 */
UCLASS()
class PRISON_API AFPSGameMode : public AGameMode
{
	GENERATED_UCLASS_BODY()

	//AFPSGameMode::AFPSGameMode(const class FObjectInitializer& PCIP);
	
	virtual void StartPlay() override; // Note that engine version 4.3 changed this method's name to StartPlay(), because of this engine versions before 4.3, or older tutorials, use BeginPlay()	
};

```

FPSGameMode.cpp

```
// Fill out your copyright notice in the Description page of Project Settings.

#include "Prison.h"
#include "FPSGameMode.h"
#include "Engine.h" //for version 4.4+

AFPSGameMode::AFPSGameMode(const class FObjectInitializer& PCIP): Super(PCIP)
{
	static ConstructorHelpers::FObjectFinder<UBlueprint> MyBlueprintObject(TEXT("Blueprint'/Game/Blueprints/BP_FPSCharacter.BP_FPSCharacter_C'"));

	if (PlayerPawnObject.Class != NULL)
	{
		DefaultPawnClass = PlayerPawnObject.Class;
	}
}

void AFPSGameMode::StartPlay()
{
	Super::StartPlay();

	StartMatch();
}

```

FPSCharacter.h

```
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "GameFramework/Character.h"
#include "FPSCharacter.generated.h"

UCLASS()
class PRISON_API AFPSCharacter : public ACharacter
{
	GENERATED_BODY()

public:
	// Sets default values for this character's properties
	AFPSCharacter();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;

	//handles moving forward/backward
	UFUNCTION()
		void MoveForward(float Val);
	//handles strafing
	UFUNCTION()
		void MoveRight(float Val);

	//sets jump flag when key is pressed
	UFUNCTION()
		void OnStartJump();
	//clears jump flag when key is released
	UFUNCTION()
		void OnStopJump();

public:
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
		UCameraComponent* FirstPersonCameraComponent;

	AFPSCharacter(const FObjectInitializer& ObjectInitializer);

	/** Pawn mesh: 1st person view (arms; seen only by self) */
	//UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
	//	USkeletalMeshComponent* FirstPersonMesh;

protected:
	//virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
	
};

```

FPSCharacter.cpp

```
// Fill out your copyright notice in the Description page of Project Settings.

#include "Prison.h"
#include "FPSCharacter.h"
    
// Sets default values
AFPSCharacter::AFPSCharacter()
{
 	// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AFPSCharacter::BeginPlay()
{
	Super::BeginPlay();    	
}

// Called every frame
void AFPSCharacter::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

}

// Called to bind functionality to input
void AFPSCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
	Super::SetupPlayerInputComponent(InputComponent);

	// set up gameplay key bindings
	InputComponent->BindAxis("MoveForward", this, &AFPSCharacter::MoveForward);
	InputComponent->BindAxis("MoveRight", this, &AFPSCharacter::MoveRight);

	InputComponent->BindAxis("Turn", this, &AFPSCharacter::AddControllerYawInput);
	InputComponent->BindAxis("LookUp", this, &AFPSCharacter::AddControllerPitchInput);

	InputComponent->BindAction("Jump", IE_Pressed, this, &AFPSCharacter::OnStartJump);
	InputComponent->BindAction("Jump", IE_Released, this, &AFPSCharacter::OnStopJump);

}

void AFPSCharacter::MoveForward(float Value)
{
	if ((Controller != NULL) && (Value != 0.0f))
	{
		// find out which way is forward
		FRotator Rotation = Controller->GetControlRotation();
		// Limit pitch when walking or falling
		if (GetCharacterMovement()->IsMovingOnGround() || GetCharacterMovement()->IsFalling())
		{
			Rotation.Pitch = 0.0f;
		}
		// add movement in that direction
		const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
		AddMovementInput(Direction, Value);
	}
}

void AFPSCharacter::MoveRight(float Value)
{
	if ((Controller != NULL) && (Value != 0.0f))
	{
		// find out which way is right
		const FRotator Rotation = Controller->GetControlRotation();
		const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
		// add movement in that direction
		AddMovementInput(Direction, Value);
	}
}

void AFPSCharacter::OnStartJump()
{
	bPressedJump = true;
}
void AFPSCharacter::OnStopJump()
{
	bPressedJump = false;
}

AFPSCharacter::AFPSCharacter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	// Create a CameraComponent 
	FirstPersonCameraComponent = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("FirstPersonCameraComponent"));
	FirstPersonCameraComponent->AttachParent = GetCapsuleComponent();

	// Position the camera a bit above the eyes
	FirstPersonCameraComponent->RelativeLocation = FVector(0, 0, 50.0f + BaseEyeHeight);
	// Allow the pawn to control rotation.
	FirstPersonCameraComponent->bUsePawnControlRotation = true;

}
```

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [March 17, 2015, 10:12pm UTC](https://forums.unrealengine.com/t/access-violation-project-crashes-on-load/311436/2 "2015-03-17T22:12:40Z")

</div>

Hey there, would you mind showing me your code?

I am not good in reviewing these error logs, but it seems you are trying to access a Nullpointer in your GameMode.

If i can trust this log, then it happened in one of your OnScreenDebugMessages.

---

<div class="post-metadata">

**Author:** ![Quaso](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Quaso](https://forums.unrealengine.com/u/Quaso)\
**Post date:** [March 18, 2015, 9:41am UTC](https://forums.unrealengine.com/t/access-violation-project-crashes-on-load/311436/3 "2015-03-18T09:41:55Z")

</div>

Hey.

I’ve included code to first message. Thank you 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_66a0fcb6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_66a0fcb6](https://forums.unrealengine.com/u/anonymous_user_66a0fcb6)\
**Post date:** [March 18, 2015, 9:49am UTC](https://forums.unrealengine.com/t/access-violation-project-crashes-on-load/311436/4 "2015-03-18T09:49:55Z")

</div>

I think the error comes from trying to use AddOnScreenDebugMessage inside your constructor. Constructors are called even before the Editor is fully loaded (during the loading pop-up). My guess is that it tries to write the message onto the Editor’s screen, which hasn’t started yet and thus you are getting a crash.

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [March 18, 2015, 9:52am UTC](https://forums.unrealengine.com/t/access-violation-project-crashes-on-load/311436/5 "2015-03-18T09:52:36Z")

</div>

Hey,

ok first of all. Please make sure that “GEngine” is not null.

Make an

```
if(GEngine)
{
    GEngine->AddOnScreen....;
}

```

Around every GEngine method you use. It could be that GEngine is still null when you call the constructor of the GameMode.

Second, try to use:

```
static ConstructorHelpers::FObjectFinder<UBlueprint> MyBlueprintObject(TEXT("Blueprint'/Game/Blueprints/BP_FPSCharacter.BP_FPSCharacter_C'"));

```

Instead of your classfinder. Since you want to find a Blueprint and use its class later, you will want to find the object first.

If this doesn’t solve the crash, then i would need some information on what the last you did was. (:

---

<div class="post-metadata">

**Author:** ![Quaso](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Quaso](https://forums.unrealengine.com/u/Quaso)\
**Post date:** [March 18, 2015, 7:04pm UTC](https://forums.unrealengine.com/t/access-violation-project-crashes-on-load/311436/6 "2015-03-18T19:04:31Z")

</div>

Thanks.

But no luck so far 😕

I’ve updated the code as you mentioned. I’ve removed all debug functions. 🙂 (OnScreenDebugMessages).

The last thing i did is creating blueprint based on my FPSCharacter. And then i’ve deleted previous GameMode blueprint.

---

<div class="post-metadata">

**Author:** ![Quaso](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Quaso](https://forums.unrealengine.com/u/Quaso)\
**Post date:** [March 18, 2015, 7:15pm UTC](https://forums.unrealengine.com/t/access-violation-project-crashes-on-load/311436/7 "2015-03-18T19:15:10Z")

</div>

Yeah. Finally. I’ve fixed it.

What i missing was “not removing binary folder”. 🙂 I’ve removed it, then rebuilt the code. Thanks for your help.

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [March 18, 2015, 7:56pm UTC](https://forums.unrealengine.com/t/access-violation-project-crashes-on-load/311436/8 "2015-03-18T19:56:59Z")

</div>

Oh ok, glad to hear you solved it (:

I will go ahead an make your comment the solving answer.
