android - MvxBind Error: "Null object can not be converted to a value type" thrown before the first screen is displayed -


i'm using mvvmcross bind data viewmodel properties in axml layout file. these bindings work correctly once application has loaded. however, there large number of "mvxbind:error" messages, in debug output log, "null object can not converted value type". of these errors occur before android app displays initial "splashscreen.axml" view. after point, bindings work expected.

it worth noting these errors occur when binding values property in custom control or binding values passed through custom converter. didn't see issues with, example, binding string text property in textview.

sample log output of error:

mvxbind:error: 17.76 problem seen during binding execution locationcurrentmovementviewmodel.isalarmsignaled visibility - problem invalidcastexception: null object can not converted value type. 07-17 20:05:51.980 i/mono-stdout( 3056): mvxbind:error: 17.76 problem seen during binding execution locationcurrentmovementviewmodel.isalarmsignaled visibility - problem invalidcastexception: null object can not converted value type. 07-17 20:05:51.980 i/mono-stdout( 3056):      @ system.convert.totype (system.object value, system.type conversiontype, iformatprovider provider, boolean try_target_to_type) [0x00000] in <filename unknown>:0  07-17 20:05:51.990 i/mono-stdout( 3056):   @ system.convert.changetype (system.object value, system.type conversiontype, iformatprovider provider) [0x00000] in <filename unknown>:0  07-17 20:05:51.990 i/mono-stdout( 3056):   @ cirrious.mvvmcross.binding.extensionmethods.mvxtypeextensions.makesafevalue (system.type propertytype, system.object value) [0x00000] in <filename unknown>:0  07-17 20:05:51.990 i/mono-stdout( 3056):   @ cirrious.mvvmcross.binding.bindings.target.mvxpropertyinfotargetbinding.makesafevalue (system.object value) [0x00000] in <filename unknown>:0        @ system.convert.totype (system.object value, system.type conversiontype, iformatprovider provider, boolean try_target_to_type) [0x00000] in <filename unknown>:0    @ system.convert.changetype (system.object value, system.type conversiontype, iformatprovider provider) [0x00000] in <filename unknown>:0    @ cirrious.mvvmcross.binding.extensionmethods.mvxtypeextensions.makesafevalue (system.type propertytype, system.object value) [0x00000] in <filename unknown>:0    @ cirrious.mvvmcross.binding.bindings.target.mvxpropertyinfotargetbinding.makesafevalue (system.object value) [0x00000] in <filename unknown>:0    @ cirrious.mvvmcross.binding.bindings.target.mvxpropertyinfotargetbinding.setvalue (system.object value) [0x00000] in <filename unknown>:0  07-17 20:05:51.990 i/mono-stdout( 3056):   @ cirrious.mvvmcross.binding.bindings.target.mvxpropertyinfotargetbinding.setvalue (system.object value) [0x00000] in <filename unknown>:0    @ cirrious.mvvmcross.binding.bindings.mvxfullbinding.updatetargetfromsource (boolean isavailable, system.object value) [0x00000] in <filename unknown>:0  [0:] mvxbind:error: 17.76 problem seen during binding execution locationcurrentmovementviewmodel.isalarmsignaled visibility - problem invalidcastexception: null object can not converted value type.       @ system.convert.totype (system.object value, system.type conversiontype, iformatprovider provider, boolean try_target_to_type) [0x00000] in <filename unknown>:0    @ system.convert.changetype (system.object value, system.type conversiontype, iformatprovider provider) [0x00000] in <filename unknown>:0    @ cirrious.mvvmcross.binding.extensionmethods.mvxtypeextensions.makesafevalue (system.type propertytype, system.object value) [0x00000] in <filename unknown>:0    @ cirrious.mvvmcross.binding.bindings.target.mvxpropertyinfotargetbinding.makesafevalue (system.object value) [0x00000] in <filename unknown>:0    @ cirrious.mvvmcross.binding.bindings.target.mvxpropertyinfotargetbinding.setvalue (system.object value) [0x00000] in <filename unknown>:0    @ cirrious.mvvmcross.binding.bindings.mvxfullbinding.updatetargetfromsource (boolean isavailable, system.object value) [0x00000] in <filename unknown>:0  07-17 20:05:51.990 i/mono-stdout( 3056):   @ cirrious.mvvmcross.binding.bindings.mvxfullbinding.updatetargetfromsource (boolean isavailable, system.object value) [0x00000] in <filename unknown>:0  

here binding throwing particular error:

<framelayout     p1:minwidth="25px"     p1:minheight="25px"     p1:layout_width="317dp"     p1:layout_height="360dp"     p1:id="@+id/movementalertoverlay"     p1:layout_margintop="135dp"     p1:layout_marginleft="639dp"     p1:background="@drawable/alert_border"     local:mvxbind="visibility locationcurrentmovementviewmodel.isalarmsignaled,converter=booltoviewstates"  /> 

code converter:

public class booltoviewstatesvalueconverter : mvxvalueconverter<bool, viewstates> {     protected override viewstates convert(bool value, system.type targettype, object parameter,                                           system.globalization.cultureinfo culture)     {         if (value)         {             return viewstates.visible;         }         return viewstates.gone;     } } 

i've tried checking "value" in converter see if null before returning anything. i've tried initializing "locationcurrentmovementviewmodel.isalarmsignaled" default value. has no effect on errors displayed.

the object "locationcurrentmovementviewmodel" nested within viewmodel associated axml layout file. set dynamically @ runtime. however, verified not cause of issue. created temp object, "tempbooltrue, boolean variable set true. used replace "locationcurrentmovementviewmodel.isalarmsignaled" in axml layout file. resulted in similar error "tempbooltrue" in place of "locationcurrentmovementviewmodel.isalarmsignaled".

i appreciate assistance solving issue.

thanks!

---- edit ----

i started working on project. so, wasn’t around when setup. there couple issues came light.

  1. the mvvmcross resources manually added. added using nuget , @ correct version, 3.0.9.
  2. i discovered splashscreen.cs had been removed. custom version of splashscreen.axml being called later in startup process.
  3. the android app starts in irregular way. appears there reasons starting app way; however, resulting solution may need change bit.

it take time sort through rest of this. but, post did me discover source of issue. stuart!

the idea of occurring

before android app displays initial "splashscreen.axml" view.

is alarming - splashscreen displayed before of mvvmcross, including binding system, bootstrapped.


reading through description, i've no idea issue is. not sure how getting binding errors before splash screen shown.

it's related makesafevalue type conversion - "believe" can correctly handle conversion null enum values - see test case on makesafevaluetest.cs#l98

to debug this, i'd recommend:

  1. ensure working latest mvvmcross releases (3.0.9 on nuget, july 13th on mvvmcross-binaries, or tagged 3.0.9 on mvvmcross repo)

  2. try creating new simple project/solution , see if can recreate problem there (it genuinely takes 1 minute create new core , droid project testing)

  3. if no solution presents during debugging, can raise issue on https://github.com/slodge/mvvmcross/issues/new , can push test repo github assist debugging.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -