So I am writing a Xamarin
application and I have built a CustomRenderer
now my method:
horizontalScrollView.ScrollTo(this.Width, 0);
keeps throwing an exception:
System.ArgumentException: 'jobject' must not be IntPtr.Zero. 10-21 12:10:41.898 E/AndroidRuntime(15053): Parameter name: jobject 10-21 12:10:41.898 E/AndroidRuntime(15053): at Android.Runtime.JNIEnv.CallIntMethod (intptr,intptr) [0x00010] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:378 10-21 12:10:41.898 E/AndroidRuntime(15053): at Android.Views.View.get_Width ()
So looking at the exception and from my breakpoints I find that the problem is that when I hover over this.Width
I get 'jobject' must not be IntPtr.Zero
instead of an integer
so I try to defensively code against this and do:
if (this.Width != IntPtr.Zero)
{
horizontalScrollView.ScrollTo(this.Width, 0);
}
but this doesnt compile and gives me the error:
Operator '!=' cannot be applied to operands of type 'int' and 'IntPtr'
So my questions is. Is there a way to check whether a value type
is equal to IntPtr.Zero
?