Search code examples
c#verificationexception

Confusing error: "VerificationException: Could not merge stack at depth 1, types not compatible"


I'm working with Unity 4.6, in case that's relevant.

The full error (runtime error, not compile-time):

VerificationException: Error verifying UtilityExtensions:DeserializeFromEditorPrefs<T> (T,string): Could not merge stack at depth 1, types not compatible: T ([boxed] Complex) X T ([boxed] Complex) at 0x01ca

Definition of DFEP:

public static T DeserializeFromEditorPrefs<T>(this T o, string prefix) where T : class {

This is the line that causes the exception (it doesn't matter what type I use; all types cause the exception; the function has no problem working with bad input data, the error is actually in the invocation):

UtilityExtensions.DeserializeFromEditorPrefs(new AbilityInfuse(),"");

I can't figure out what's going on. I use this function in other projects, so maybe it's a project setting, but I haven't been able to find any information on what could be causing this error. There are some variants of this function as well, none of which seem to work. Other generic extensions from the same file are working with no problem, it is only this one set of functions that won't run.

AbilityInfuse is marked Serializable, and even with a serializable empty class the problem persists.


Solution

  • Unity uses high security settings when building to Web Player. I don't know exactly what any of the settings are, but switching to PC build removed whatever security setting it was that was preventing the function from being "verified".