Runtime error may be caused by multiple reasons. First thing is to check the Log–usually it will not show much by default. Try print debug messages to the Log and track down the problem.
Some tricky cases I have ran into are:
- File path error / file cannot by loaded in runtime. VS2017 complies the code and saves it as binaries. So the relative filepath used in the code will be pointing to the wrong place. A better practice will be, since the data file loaded is an asset, to keep the file in the Contents/Data/ folder, and expose a Upropery in the Editor to get the filepath.
- Dynamic casting. VS2017 hides the RTTI settings for UE4. You need to forcefully enable it in the Build.cs file.
- Linking error. If there are cpp files in the static library imported, they may not be included in the build, even if it shows as imported. It is probably better to just have everything in the header files if it makes sense.
- Runtime error. Usually due to initialization.