Access violation on UMaterialInstance* Variable

I have a UMaterialInstance* variable called SkyMaterialInst. Whenever I try to build the editor, I get a Access violation exception thrown by the compiler. Does anyone know how to fix this error?

Code:

    /**
	Create the sky material
	*/
	SkyMaterialInst = SkySphereMesh->CreateDynamicMaterialInstance(0, SkyMaterial);

	FScalarParameterValue spvCloudSpeed = FScalarParameterValue();
	spvCloudSpeed.ParameterName = "Cloud speed";
	spvCloudSpeed.ParameterValue = CloudSpeed;
	SkyMaterialInst->ScalarParameterValues.Add(spvCloudSpeed); // This line throws the exception

Image of exception:

26252-error.jpg

I tried initializing the SkyMaterialInst with the code below, but it triggers a break-point and writes an error message, seen below, in the output window.

Code:

SkyMaterialInst = Cast<UMaterialInstance>(StaticConstructObject(UMaterialInstance::StaticClass(),NULL, TEXT("SkyMaterialInst")));

Output message:

[2015.01.10-18.55.28:172][ 0]LogUObjectGlobals:Warning: Class which was marked abstract was trying to be loaded. It will be nulled out on save. SkyMaterialInst MaterialInstance
Ensure condition failed: false [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.6\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 1597]
Class which was marked abstract was trying to be loaded. It will be nulled out on save. SkyMaterialInst MaterialInstance
UE4Editor.exe has triggered a breakpoint.

I am still lost on this, so any help or suggestions will be much appreciated.

I ended up using my original code. It turns out that my error came from the fact that I was not initializing my SkyMaterial variable correctly and that was causing my SkyMaterialInst variable to be initialized incorrectly.