Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Xamarin.iOS 6.4.4.12 - System.NullReferenceException when trying to cast null value to interface

$
0
0

Following code

    A TestMethod () 
    {
        TestProp = null;
        A testVariable = (A)TestProp;

        return testVariable;
    }

    private A testProp;

    public object TestProp 
    {
        get {
            return this.testProp;
        }
        set {
            this.testProp = (A)value;
        }
    }

    interface A
    {

    }

breaks at line

TestProp = null;

If commented out, then it breaks on

A testVariable = (A)TestProp;

In both cases it fails on

System.NullReferenceException : Object reference not set to an instance of an object
    at Test.Program.set_TestProp (System.Object value) [0x00001] ...

This code is working in Visual Studio 2012 and was working in older versions of Xamarin.

Maybe there is some bug in latest Mono implementation? Do you experience similar problems?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>