Hello All,
I am moving customization changes from nopcommerce 4.3 to 4.4.0. 4.4 is completely built with async and await methods. I am new to this async await coding.
When I do simple method changes I am getting Object reference not set to an instance of an object error. I have created a simple method below after stripping other code to show the issue.
Below is the code
public virtual async Task<WishlistModel> PrepareWishlistModelAsync1(WishlistModel model, IList<ShoppingCartItem> cart, bool isEditable = true)
{
List<Product> lst1 = new List<Product>();
lst1.Add(new Product { Id = 123, Name = "Product 1" });
var products1 = await _productModelFactory.PrepareProductOverviewModelsAsync(lst1);
return model;
}
I am getting the object reference error at below line
var products1 = await _productModelFactory.PrepareProductOverviewModelsAsync(lst1);
I am unable to understand what mistake I am making. I tried to change from async method to the normal method but still getting the same error.
Thank you,
Sateesh M.