Why my editor crashes when I compile the code in VS?

When I try to compile my c++ code in VS the editor crashes. And even if I first close the editor, compile and try to open it again I still can’t open it.

I receive this crash report:

MachineId:77333925497143DD7085E6B3DE211EFA
EpicAccountId:299ff08a6c6846ac96c34d30bd6079f9

Unknown exception - code 00000001 (first/second chance not available)

Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.7\Engine\Source\Runtime\CoreUObject\Private\UObject\Obj.cpp] [Line: 60] 
Using incorrect object initializer.

KERNELBASE + 24684 bytes
UE4Editor_Core!FOutputDeviceWindowsError::Serialize() + 292 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\windows\windowsplatformoutputdevices.cpp:95]
UE4Editor_Core!FMsg::Logf__VA() + 463 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\misc\outputdevice.cpp:531]
UE4Editor_CoreUObject!UObject::CreateDefaultSubobject() + 342 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\obj.cpp:61]
UE4Editor_MyProject3!ADragonCharacter::ADragonCharacter() + 279 bytes [c:\users\kazuy_000\documents\unreal projects\myproject3\source\myproject3\dragoncharacter.cpp:26]
UE4Editor_CoreUObject!UClass::CreateDefaultObject() + 435 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\class.cpp:2535]
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<void __cdecl(void)>::ExecuteIfSafe() + 7 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:921]
UE4Editor_Core!TBaseMulticastDelegate<void>::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]

Can someone help me?

Forget about it, I have found the problem.

Care to share the solution in case it’s helpful to others. Given the callstack, I’m guessing there was something invalid in your ADragonCharacter constructor?

well… I put every line with comment slashes and removed one by one… the error started here:

CameraBoom->CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
	CameraBoom->AttachTo(RootComponent);
	CameraBoom->bEnableCameraRotationLag = true;
	CameraBoom->TargetArmLength = 700.0f;
	CameraBoom->bUsePawnControlRotation = true;
	CameraBoom->CameraLagSpeed = 10.0f;

	FollowCamera->CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
	FollowCamera->AttachTo(CameraBoom, USpringArmComponent::SocketName);
	FollowCamera->bUsePawnControlRotation = false;

This is the whole code:

GetCapsuleComponent()->InitCapsuleSize(400.0f, 350.0f);

	bUseControllerRotationPitch = false;
	bUseControllerRotationRoll = false;
	bUseControllerRotationYaw = false;

	GetCharacterMovement()->bCheatFlying = true;
	GetCharacterMovement()->RotationRate = FRotator(0.0f, 540.0f, 0.0f);
	GetCharacterMovement()->AirControl = 0.2f;
	GetCharacterMovement()->BrakingDecelerationFlying = 10.0f;
	GetCharacterMovement()->MaxFlySpeed = 300.0f;
	GetCharacterMovement()->bOrientRotationToMovement = true;
	GetCharacterMovement()->JumpZVelocity = 200.0f;

	CameraBoom->CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
	CameraBoom->AttachTo(RootComponent);
	CameraBoom->bEnableCameraRotationLag = true;
	CameraBoom->TargetArmLength = 700.0f;
	CameraBoom->bUsePawnControlRotation = true;
	CameraBoom->CameraLagSpeed = 10.0f;

	FollowCamera->CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
	FollowCamera->AttachTo(CameraBoom, USpringArmComponent::SocketName);
	FollowCamera->bUsePawnControlRotation = false;

Thanks.

Here’s a link to the follow up question: Why this piece of code makes my editor to crash? - Mobile - Epic Developer Community Forums

Errors are it those two lines of code

CameraBoom->CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
FollowCamera->CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));

it should be

CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));

instead.