Whenever I'm using strings in expressions in an RDLC report the report crashes

Haesen, Bart 0 Reputation points
2025-10-22T16:09:37.2266667+00:00

I'm relying heavily on RDLC reports in my web forms applications. I'm using the latest version through Nuget.

Whenever I'm using a string in the expression builder I receive the following error:

Microsoft.Reporting.WebForms.LocalProcessingException: An error occurred during local report processing. ---> Microsoft.Reporting.DefinitionInvalidException: The definition of the report 'xxxx.rdlc' is invalid. ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred while compiling expressions. Native compiler return value: ‘[BC31424] Type 'System.CodeDom.Compiler.GeneratedCodeAttribute' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' has been forwarded to assembly 'System.Private.CoreLib'. Either a reference to 'System.Private.CoreLib' is missing from your project or the type 'System.CodeDom.Compiler.GeneratedCodeAttribute' is missing from assembly 'System.Private.CoreLib'.’. at Microsoft.ReportingServices.RdlExpressions.ExprHostCompiler.ParseErrors(CompilerResults results) at Microsoft.ReportingServices.RdlExpressions.ExprHostCompiler.InternalCompile(AppDomain compilationTempAppDomain, Boolean refusePermissions) at Microsoft.ReportingServices.RdlExpressions.ExprHostCompiler.<>c__DisplayClass33_0.<Compile>b__0() at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.<>c__DisplayClass1_0.<Run>b__0(Object state) at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state) at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.Run(ContextBody callback) at Microsoft.ReportingServices.RdlExpressions.ExprHostCompiler.Compile(IExpressionHostAssemblyHolder expressionHostAssemblyHolder, AppDomain compilationTempAppDomain, Boolean refusePermissions, PublishingVersioning versioning) at Microsoft.ReportingServices.ReportPublishing.ReportPublishing.Phase3(ParameterInfoCollection& parameters, Dictionary`2& groupingExprCountAtScope) at Microsoft.ReportingServices.ReportPublishing.ReportPublishing.InternalCreateIntermediateFormat(Stream definitionStream, String& description, String& language, ParameterInfoCollection& parameters, DataSourceInfoCollection& dataSources, DataSetInfoCollection& sharedDataSetReferences, UserLocationFlags& userReferenceLocation, ArrayList& dataSetsName, Boolean& hasExternalImages, Boolean& hasHyperlinks, Byte[]& dataSetsHash) at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.CompileOdpReport(PublishingContext reportPublishingContext, PublishingErrorContext errorContext, String& reportDescription, String& reportLanguage, ParameterInfoCollection& parameters, DataSourceInfoCollection& dataSources, DataSetInfoCollection& sharedDataSetReferences, UserLocationFlags& userReferenceLocation, ArrayList& dataSetsName, Boolean& hasExternalImages, Boolean& hasHyperlinks, Byte[]& dataSetsHash) at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.CreateIntermediateFormat(PublishingContext reportPublishingContext) at Microsoft.Reporting.ReportCompiler.CompileReport(ICatalogItemContext context, Byte[] reportDefinition, Boolean generateExpressionHostWithRefusedPermissions, ControlSnapshot& snapshot) --- End of inner exception stack trace --- at Microsoft.Reporting.ReportCompiler.CompileReport(ICatalogItemContext context, Byte[] reportDefinition, Boolean generateExpressionHostWithRefusedPermissions, ControlSnapshot& snapshot) at Microsoft.Reporting.LocalService.GetCompiledReport(PreviewItemContext itemContext, Boolean rebuild, ControlSnapshot& snapshot) at Microsoft.Reporting.LocalService.CompileReport() at Microsoft.Reporting.WebForms.LocalReport.EnsureExecutionSession() --- End of inner exception stack trace --- at Microsoft.Reporting.WebForms.LocalReport.EnsureExecutionSession()

Below are some expressions I tried, they al return the above error message:

="Some text"
="Last update: " & Format(Globals!ExecutionTime,"yyyy-MM-dd")
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
{count} votes

1 answer

Sort by: Most helpful
  1. Haesen, Bart 0 Reputation points
    2025-10-23T11:25:53.5333333+00:00

    Environment & Setup

    • .NET Framework 4.8
    • Microsoft RDLC Report Designer 18.0.0
    • WebForms

    Error Context

    I tried following scenarios where the error occurs:

    • Textbox with only pagenumber: =Globals!PageNumber
    • Textbox with current date time: =Now() and =FormatDateTime(Now(),DateFormat.ShortDate)
    • Textbox with user ID: =User!UserID

    The error happens at runtime, there is no design time preview.
    It's consistent through all reports

    Expression Details

    The expressions are string concatenations: static text with values from the data source.

    Using only values from the data source e.g.: =First(Fields!DateFrom.Value, "NeedCompletionData") works fine.

    A Tablix with data from the data source works fine.

    When you use static text with data source fields it crashes: ="Date From: " & First(Fields!DateFrom.Value, "NeedCompletionData")

    Project Configuration

    System.CodeDom is not referenced in the project as I expect everything to get reference by adding the NuGet packages.

    I'm using Microsoft.ReportingServices.ReportViewerControl.WebForms 150.1652.0

    Troubleshooting attempts

    Yes I have tried removing the expressions. As stated above then it works, but this is no option.

    I added System.CodeDom through NuGet package 9.0.10, but that did not change the behavior.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.