Hi,
I’m having an issue where unity crashes when methods on covariant generic interfaces are called. I’ve comment out any work performed by the methods to confirm it is defiantly the act of calling the methods that causes the crash. Here is a snippet from the crash error log:
Unity Player [version: Unity 4.3.3f1_c8ca9b6b9936]
mono.dll caused an Access Violation (0xc0000005)
in module mono.dll at 0023:100010c6.
…
…
Read from location 00000000 caused an access violation.
I’ve searched around the web for similar issues but couldn’t find anything that seemed related. (same result different cause).
As far as I can tell (correct me if I’m wrong) variance in generic interfaces should work with mono in the current version of unity (with the target framework set at .net 4.0).
Here is a snippet of the way I’ve implement the interface in case I’m the cause of the problem… (variable names changed/code cuts for clarity)
//Interface
public interface ICovariant<out T> {
void TestMethod();
}
//Implemented on Class
public class TestClass<T> : ICovariant<T> where T : BaseType {
public void TestMethod() {
int x = 1;
}
}
//Called from GameObject Component
public class BaseType : GameBase {
void Start() {
ICovariant<BaseType> MethodObject = new TestClass<DerivedType>();
MethodObject.TestMethod();
}
}
Is the problem with Unity or myself?
Let me know if you need any further information and thanks for the help in advance.