Editor crashes on launch with error in Casts.cpp

I was experimenting with the c++ code of a project when suddenly the editor crashed. I reverted all of the changes I had made and rebuilt the solution but it still crashes whenever I try to open it in the editor. I get the following error message in the crash report:

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

"Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.10\Engine\Source\Runtime\CoreUObject\Private\Templates\Casts.cpp] [Line: 11] 
Cast 

UE4Editor_Core!FDebug::AssertFailed() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\misc\outputdevice.cpp:374]
UE4Editor_CoreUObject!CastLogError() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\coreuobject\private\templates\casts.cpp:12]
UE4Editor_Engine!CastChecked<ULevel,UObject>() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\coreuobject\public\templates\casts.h:195]
UE4Editor_Engine!TActorIteratorBase<FActorIterator>::operator++() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\public\engineutils.h:253]
UE4Editor_Engine!UWorld::UpdateCullDistanceVolumes() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\world.cpp:1383]
UE4Editor_Engine!UWorld::InitializeNewWorld() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\world.cpp:1095]
UE4Editor_Engine!UWorld::CreateWorld() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\world.cpp:1170]
UE4Editor_Engine!UEngine::Init() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\unrealengine.cpp:801]
UE4Editor_UnrealEd!UEditorEngine::InitEditor() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\editor\unrealed\private\editorengine.cpp:430]
UE4Editor_UnrealEd!UEditorEngine::Init() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\editor\unrealed\private\editorengine.cpp:585]
UE4Editor_UnrealEd!UUnrealEdEngine::Init() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\editor\unrealed\private\unrealedengine.cpp:50]
UE4Editor!FEngineLoop::Init() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\launchengineloop.cpp:2094]
UE4Editor_UnrealEd!EditorInit() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\editor\unrealed\private\unrealed.cpp:63]
UE4Editor!GuardedMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\launch.cpp:133]
UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
kernel32
ntdll

I found the file it was complaining about (Casts.cpp) and saw that some errors are present. The main one seems to be “Cannot open source file “CoreUObjectPrivate.h””

80818-casts+error.png

Anyone have any ideas on how to fix this?

Hey -

Can you post the exact compile error you’re getting now? Based on where the callstack mentions the Casts.cpp file it appears that an attempt to make a cast call is failing somewhere. Can you post the class(es) that you were working in when this crash occurred?

I don’t think it’s a problem in the class I was editing (APaperCharacter class), as in an attempt to find the problem I completely commented out most of the logic in the MyPaperCharacter.cpp file I was working on and rebuilt the solution. If you would still like to take a look at the file I would be happy to post it, but it is around 300 lines long so would it be best to upload the file to a download site or simply copy/past it here?

It would work if you are able to attach the files (.h and .cpp) themselves here or you can upload them someone and provide the link here to download.

link text

Thanks for taking a look at this for me. I have attached the .h and .cpp of my main character class. This is the version that should work (but doesn’t), as I reverted the changes after it started crashing.

Because the crash is happening when the project is being opened, it is likely that a file is trying to access another file or class before it has been fully setup which the editor can’t handle. It’s possible that another asset was edited that caused the editor to have this conflict. Before this crash started occurring, were you working in any blueprints where you added cast calls? Something else you can test is to remove the Content folder from the project directory and slowly reintroduce it and its subfolders to see if a specific asset is corrupted.

I don’t remember using any casts in the code or in blueprints. I actually didn’t use any blueprint scripting as I was trying to stick to C++. I removed the content folder like you suggested but the same crash happens with the same error.

I’m not sure if this counts as a ‘fix’, but I just made a new project and copy/pasted my classes and assets. It works now.