NullReferenceException when calling async DataPortal_Update

NullReferenceException when calling async DataPortal_Update

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


TSF posted on Friday, October 19, 2012

I'm not sure what I'm doing incorrectly to cause this exception.  My factory method is as follows:

         public static async Task UpdateSettingValueAsync(byte levelId, bool isActive)
        {
            var criteria = new SettingCriteria();
            criteria.LevelId = levelId;
            criteria.IsActive = isActive;
            await DataPortal.UpdateAsync(criteria);
        }

 And the actual DP method is as follows:

        [RunLocal]
        private void DataPortal_Update(SettingCriteria criteria) { ... }

When the line "await DataPortal.UpdateAsync(criteria)" is called in the factory method, I get a NullReferenceExcpetion.  It's like it can't find a DataPortal_Update method that has as its parameter a SettingCriteria object.

Should I be able to call an async DP_Update method without expecting to get a return type back?

JonnyBee replied on Saturday, October 20, 2012

No -  the dataportal method must be async and return a Task.

Copyright (c) Marimer LLC