Hello,
We’re trying to convert an old project (quite complex app, from one of our clients) but the converted app fails withe the following error
NullReferenceException: Object reference not set to an instance of an object.
ASPNETMaker2024.Models.Timesheets.FormatInteger(object value, string pattern) in aspnetfn.cs
-
public static string FormatInteger(object? value, string? pattern = null)
{
if (Empty(value))
return "";
long? val = IsFormatted(value) ? ParseInteger(ConvertToString(value)) : ConvertToNullableInt64(value);
pattern = !Empty(pattern) ? pattern : NumberFormat;
pattern = pattern.Split(".")[0]; // Remove decimal places in the pattern
return val.HasValue ? val.Value.ToString(pattern, CurrentNumberFormat).Replace(LatinDigits, NativeDigits) : ConvertToString(value);
}
/// <summary>
/// Parse number
/// </summary>
ASPNETMaker2024.Models.Timesheets+PrevNextPager.Render() in PrevNextPager.cs
-
string firstBtn = $@"<button class=""btn btn-default{FirstButton.DisabledClass}"" data-value=""first"" data-table=""{Table.TableVar}"" title=""{Language.Phrase("PagerFirst")}"" {FirstButton.GetAttributes(url, action)}><i class=""fa-solid fa-angles-left ew-icon""></i></button>";
string prevBtn = $@"<button class=""btn btn-default{PrevButton.DisabledClass}"" data-value=""prev"" data-table=""{Table.TableVar}"" title=""{Language.Phrase("PagerPrevious")}"" {PrevButton.GetAttributes(url, action)}><i class=""fa-solid fa-angle-left ew-icon""></i></button>";
string nextBtn = $@"<button class=""btn btn-default{NextButton.DisabledClass}"" data-value=""next"" data-table=""{Table.TableVar}"" title=""{Language.Phrase("PagerNext")}"" {NextButton.GetAttributes(url, action)}><i class=""fa-solid fa-angle-right ew-icon""></i></button>";
string lastBtn = $@"<button class=""btn btn-default{LastButton.DisabledClass}"" data-value=""last"" data-table=""{Table.TableVar}"" title=""{Language.Phrase("PagerLast")}"" {LastButton.GetAttributes(url, action)}><i class=""fa-solid fa-angles-right ew-icon""></i></button>";
string disabled = Modal ? " disabled" : "";
string pagePhrase = Language.Phrase(PagePhraseId);
string pageNumber = $@"<!-- current page number --><input class=""form-control ew-page-number"" type=""text"" data-ew-action=""change-page"" data-ajax=""{ajax}"" data-url=""{url}"" data-pagesize=""{PageSize}"" data-pagecount=""{PageCount}"" {context} name=""{PageNumberName}"" value=""{FormatInteger(CurrentPageNumber)}""{disabled}>";
html += $@"<div class=""ew-pager"">
<span>{pagePhrase} </span>
<div class=""ew-prev-next"">
<div class=""input-group input-group-sm"">
<!-- first page button -->
{firstBtn}
AspNetCore.Views_Home_ApplicationUsersList.ExecuteAsync() in ApplicationUsersList.cshtml
-
}
</form><!-- /.ew-list-form -->
@{ applicationUsersList.CloseRecordset(); }
@if (!applicationUsersList.IsExport()) {
<div class="card-footer ew-grid-lower-panel">
@if (!applicationUsersList.IsGridAdd && !(applicationUsersList.IsGridEdit && applicationUsersList.ModalGridEdit) && !applicationUsersList.IsMultiEdit) {
@Html.Raw(applicationUsersList.Pager.Render())
}
<div class="ew-list-other-options">
@applicationUsersList.OtherOptions.RenderBody("bottom")
</div>
</div>
}
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, bool invokeViewStarts)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0<TFilter, TFilterAsync>(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
ASPNETMaker2024.Models.Timesheets+MaintenanceMiddleware.Invoke(HttpContext context) in MaintenanceMiddleware.cs
-
CssFile(Config.ProjectStylesheetFilename), // {3}
statusCode, // {4}
Language.Phrase(statusCode + "Desc") // {5}
);
await context.Response.WriteAsync(content, Encoding.UTF8);
} else { // Go to next if not in Maintenance mode
await next.Invoke(context);
}
}
}
} // End Partial class
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Marvin.Cache.Headers.HttpCacheHeadersMiddleware.HandleResponse(HttpContext httpContext)
Marvin.Cache.Headers.HttpCacheHeadersMiddleware.Invoke(HttpContext httpContext, IValidatorValueInvalidator validatorValueInvalidator)
Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
the error persists in every grid page which contains some data (at least one row). the error stack points to FormatInteger(object value, string pattern)
in aspnetfn.cs
Anyone could give us a hint how to get past this issue?
Regards