WINRT ManagedObjectBase bug

WINRT ManagedObjectBase bug

Old forum URL: forums.lhotka.net/forums/t/11855.aspx


ayubu posted on Tuesday, February 26, 2013

Hi Rocky

, i am using latest code in the repo. I noted  if you create a command object with a business object property and if trying to LoadProperty in the Execute method i get a  null reference exception from the csla assembly.

 

i noted the method in the ManagedObjectBase

 

 protected virtual void LoadProperty(IPropertyInfo propertyInfo, object newValue)
        {
            var t = this.GetType();
            var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
            var method = t.GetMethods(flags).FirstOrDefault(c => c.Name == "LoadProperty" && c.IsGenericMethod);
            var gm = method.MakeGenericMethod(propertyInfo.Type);
            var p = new object[] { propertyInfo, newValue };
            gm.Invoke(this, p);
        }

 

if i change the method to this , the issue disappears

  protected virtual void LoadProperty(IPropertyInfo propertyInfo, object newValue)
        {
            var t = this.GetType();
            //var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
            var method = t.GetRuntimeMethods().FirstOrDefault(c => c.Name == "LoadProperty" && c.IsGenericMethod);
            var gm = method.MakeGenericMethod(propertyInfo.Type);
            var p = new object[] { propertyInfo, newValue };
            gm.Invoke(this, p);
        }

 

 

In the attched repro the code are in the file FailOne.vb

RockfordLhotka replied on Tuesday, February 26, 2013

Thank you.

https://github.com/MarimerLLC/csla/issues/50

Copyright (c) Marimer LLC