While testing a modified SSRS report I noticed that certain values were not shown, only the message:
Neither the ReportServerService__*.log or ExecutionLog* database views contained any clues about the cause.
I used procdump to log exception messages from ReportingServicesService.exe with:
procdump.exe -f "" -l -e 1 ReportingServicesService.exe
Part of the result was:
[13:46:39] Exception: E0434F4D.System.InvalidOperationException ("Nullable object must have a value.") [13:46:39] Exception: E0434F4D.System.FormatException ("Input string was not in a correct format.") [13:46:39] Exception: E0434F4D.System.FormatException ("Input string was not in a correct format.") [13:46:39] Exception: E0434F4D.System.InvalidCastException ("Conversion from string "Nullable object must have a valu" to type 'Decimal' is not valid.")
These exceptions were unexpected and puzzling. Additional examination was required.
I attached WinDbg (x64) to ReportingServicesService.exe and configured event filters to break on CLR exceptions.
Refreshed the report again and the first exception was thrown.
Verified the exception with:
The result was:
Exception object: 000000030d4c2f90 Exception type: System.InvalidOperationException Message: Nullable object must have a value. InnerException: <none> StackTrace (generated): <none> StackTraceString: <none> HResult: 80131509
Checked the .NET call stack with:
Part of the result was:
Child-SP RetAddr Call Site 0000000016d1b150 00007ff98347a650 System.ThrowHelper.ThrowInvalidOperationException(System.ExceptionResource) 0000000016d1b190 00007ff9271033ef System.Nullable`1[[System.Double, mscorlib]].op_Explicit(System.Nullable`1<Double>) 0000000016d1b1c0 00007ff927103310 ReportExprHostImpl+CustomCodeProxy.UnitConvertSlim(Double, System.String, System.String, System.String, System.Nullable`1<Double>, System.Nullable`1<Double>) 0000000016d1b290 00007ff92622c452 ReportExprHostImpl+Textbox9_TextBoxExprHost+Paragraph00_ParagraphExprHost+TextRun00_TextRunExprHost.get_ValueExpr() 0000000016d1b360 00007ff92622bedf Microsoft.ReportingServices.RdlExpressions.ReportRuntime.EvaluateTextRunValueExpression(Microsoft.ReportingServices.ReportIntermediateFormat.TextRun)
Also checked the .NET call stack including parameters and locals with:
However the majority of these were optimized away, only showing: <no data>
It’s relevant to mention that the report code in question contains multiple UnitConvert(…) functions with different parameter overloads.
At this point I made a mistake by reading UnitConvertSlim as UnitConvert. I mistakenly thought that the right UnitConvert(…) function was called.
I wanted to set a breakpoint to inspect the status before the exception occured, but this was complicated by the fact that ReportExprHostImpl+CustomCodeProxy is generated code.
(Managed to set breakpoints, but they were not hit, most likely because they were on previous versions of the generated code)
Being challenged by this, I decided to do something else.
I compared the old and new version of the report and realised that UnitConvertSlim(…) was another function than expected.
Therefore I decided to run the VB code in a simple, separate VB application, to enable normal debugging.
This required simulating certain SSRS classes and properties, in this case Report.Parameters(…).
By debugging the separate VB application I realized that the expected UnitConvert(…) function did not exist!
Instead another UnitConvert(…) function was found and called. Some parameters were converted to other types and this was the root cause of the problem…
I implemented the missing UnitConvert(…) function and this solved the problem, both in the separate VB application and in SSRS.
SSRS VB code may fail in unexpected ways, if a required function overload does not exist.
If debugging VB code in SSRS is problematic, try debugging it outside of SSRS in a separate program.