locked
Error using any built-in fields RRS feed

  • Question

  • I am using Visual Studio 2010 to create ASP.NET pages with various rdlc reports. I am using an Object data source to query an Oracle database using ODBC. Everything seems to work fine with the exception of built-in fields. For example, I am unable to print  "page 1 of 4" at the top of the report. It compiles fine, but simply shows "#Error" in place of the built-in fields. I worked around it for the date and time by using the "common function" Now(). That works fine. But any time I use =Globals!PageNumber, or Globals! anthing at all, I just get "#Error" printed, with no clue as to what is wrong. I was expecting to find many people with this issue, but except for the other programmer in my office, I haven't found anyone with this issue.

    To be clear, I am able to get all the data to print as I would expect. It is only the built-in fields that don't seem to work.

    Am I missing a setting somewhere? Any ideas?

     

    Tuesday, June 8, 2010 8:48 PM

All replies

  • Hi vusprog,

    I have not heard anyone mention this issue. Can you send me a generic RDLC I can try in house here at MS? Bradsy@removemeMicrosoft.com. My guess is that it is probably something easy to fix and help you out.

     


    Brad Syputa, Microsoft Reporting Services This posting is provided "AS IS" with no warranties.
    Thursday, June 10, 2010 1:02 AM
  • Thanks Brad,

     

    I'm not sure if I understand what you mean by a generic RDLC. What I tried was to create a very simple one with just a header and a page number built-in field. It gives the same error. Please let me know if this is not what you meant, or if you need more info. Here is the rdlc:

     

    <?xml version="1.0" encoding="utf-8"?>

    <Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">

      <DataSources>

        <DataSource Name="appdata">

          <ConnectionProperties>

            <DataProvider>System.Data.DataSet</DataProvider>

            <ConnectString>/* Local Connection */</ConnectString>

          </ConnectionProperties>

          <rd:DataSourceID>140bf032-3095-4005-9912-758f7e8179e2</rd:DataSourceID>

        </DataSource>

      </DataSources>

      <Body>

        <Height>2in</Height>

        <Style />

      </Body>

      <Width>6.5in</Width>

      <Page>

        <PageHeader>

          <Height>1in</Height>

          <PrintOnFirstPage>true</PrintOnFirstPage>

          <PrintOnLastPage>true</PrintOnLastPage>

          <ReportItems>

            <Textbox Name="PageNumber">

              <CanGrow>true</CanGrow>

              <KeepTogether>true</KeepTogether>

              <Paragraphs>

                <Paragraph>

                  <TextRuns>

                    <TextRun>

                      <Value>=Globals!PageNumber</Value>

                      <Style />

                    </TextRun>

                  </TextRuns>

                  <Style />

                </Paragraph>

              </Paragraphs>

              <rd:DefaultName>PageNumber</rd:DefaultName>

              <Top>0.34042in</Top>

              <Left>3.7675in</Left>

              <Height>0.25in</Height>

              <Width>1in</Width>

              <Style>

                <Border>

                  <Style>None</Style>

                </Border>

                <PaddingLeft>2pt</PaddingLeft>

                <PaddingRight>2pt</PaddingRight>

                <PaddingTop>2pt</PaddingTop>

                <PaddingBottom>2pt</PaddingBottom>

              </Style>

            </Textbox>

            <Textbox Name="Textbox3">

              <CanGrow>true</CanGrow>

              <KeepTogether>true</KeepTogether>

              <Paragraphs>

                <Paragraph>

                  <TextRuns>

                    <TextRun>

                      <Value>Generic Test Report for Brad</Value>

                      <Style />

                    </TextRun>

                  </TextRuns>

                  <Style />

                </Paragraph>

              </Paragraphs>

              <rd:DefaultName>Textbox3</rd:DefaultName>

              <Top>0.34042in</Top>

              <Left>0.44458in</Left>

              <Height>0.25in</Height>

              <Width>1.97917in</Width>

              <ZIndex>1</ZIndex>

              <Style>

                <Border>

                  <Style>None</Style>

                </Border>

                <PaddingLeft>2pt</PaddingLeft>

                <PaddingRight>2pt</PaddingRight>

                <PaddingTop>2pt</PaddingTop>

                <PaddingBottom>2pt</PaddingBottom>

              </Style>

            </Textbox>

          </ReportItems>

          <Style>

            <Border>

              <Style>None</Style>

            </Border>

          </Style>

        </PageHeader>

        <LeftMargin>1in</LeftMargin>

        <RightMargin>1in</RightMargin>

        <TopMargin>1in</TopMargin>

        <BottomMargin>1in</BottomMargin>

        <Style />

      </Page>

      <rd:ReportID>48f5f7dc-e410-41fa-832d-454bf71e6e8c</rd:ReportID>

      <rd:ReportUnitType>Inch</rd:ReportUnitType>

    </Report>

     

    Thursday, June 10, 2010 2:17 PM
  • I have the exact same problem.  VS2010, RDLC, try to place a built-in expression on the form but only get #Error in its place.  I'm trying to use ReportName.

    Thanks,

    Eric Selje

    Tuesday, June 29, 2010 7:45 PM
  • I have the same problem in VS2010 RDLC, even with parameters.

    =Globals!ReportName  --> gives #Error in reportviewer

    =User!Language  --> gives #Error in reportviewer

    =Parameters!param.Value  --> gives #Error in reportviewer

    =Now()  --> works!

    Wednesday, June 30, 2010 9:31 AM
  • I am unable to reproduce any of the above errors. 
    
    I created a new Web project in VS2010. Added a report viewer and a new RDLC file. I took the above RDL and added a few more globals. I hit ctrl-F5 and all of the globals work. Anything else I need to change or do to reproduce the issue? Is it possible that you are running in a lower trust environment?
    
    
    
    <?xml version="1.0" encoding="utf-8"?>
    
    <Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">
    
    <DataSources>
    
    <DataSource Name="appdata">
    
    <ConnectionProperties>
    
    <DataProvider>System.Data.DataSet</DataProvider>
    
    <ConnectString>/* Local Connection */</ConnectString>
    
    </ConnectionProperties>
    
    <rd:DataSourceID>140bf032-3095-4005-9912-758f7e8179e2</rd:DataSourceID>
    
    </DataSource>
    
    </DataSources>
    
    <Body>
    
    <ReportItems>
    
    <Textbox Name="Textbox1">
    
    <CanGrow>true</CanGrow>
    
    <KeepTogether>true</KeepTogether>
    
    <Paragraphs>
    
    <Paragraph>
    
    <TextRuns>
    
    <TextRun>
    
    <Label>=Globals.ReportName</Label>
    
    <Value>=Globals.ReportName</Value>
    
    <ToolTip>=Globals.ReportName</ToolTip>
    
    <Style />
    
    </TextRun>
    
    </TextRuns>
    
    <Style />
    
    </Paragraph>
    
    </Paragraphs>
    
    <rd:DefaultName>Textbox1</rd:DefaultName>
    
    <Top>0.3925in</Top>
    
    <Left>0.44458in</Left>
    
    <Height>0.25in</Height>
    
    <Width>1.97917in</Width>
    
    <Style>
    
    <Border>
    
    <Style>None</Style>
    
    </Border>
    
    <PaddingLeft>2pt</PaddingLeft>
    
    <PaddingRight>2pt</PaddingRight>
    
    <PaddingTop>2pt</PaddingTop>
    
    <PaddingBottom>2pt</PaddingBottom>
    
    </Style>
    
    </Textbox>
    
    <Textbox Name="Textbox2">
    
    <CanGrow>true</CanGrow>
    
    <KeepTogether>true</KeepTogether>
    
    <Paragraphs>
    
    <Paragraph>
    
    <TextRuns>
    
    <TextRun>
    
    <Label>=User!Language </Label>
    
    <Value>=User!Language </Value>
    
    <ToolTip>=User!Language </ToolTip>
    
    <Style />
    
    </TextRun>
    
    </TextRuns>
    
    <Style />
    
    </Paragraph>
    
    </Paragraphs>
    
    <rd:DefaultName>Textbox2</rd:DefaultName>
    
    <Top>1.40292in</Top>
    
    <Left>0.44458in</Left>
    
    <Height>0.25in</Height>
    
    <Width>1.97917in</Width>
    
    <ZIndex>1</ZIndex>
    
    <Style>
    
    <Border>
    
    <Style>None</Style>
    
    </Border>
    
    <PaddingLeft>2pt</PaddingLeft>
    
    <PaddingRight>2pt</PaddingRight>
    
    <PaddingTop>2pt</PaddingTop>
    
    <PaddingBottom>2pt</PaddingBottom>
    
    </Style>
    
    </Textbox>
    
    </ReportItems>
    
    <Height>2in</Height>
    
    <Style />
    
    </Body>
    
    <Width>6.5in</Width>
    
    <Page>
    
    <PageHeader>
    
    <Height>1in</Height>
    
    <PrintOnFirstPage>true</PrintOnFirstPage>
    
    <PrintOnLastPage>true</PrintOnLastPage>
    
    <ReportItems>
    
    <Textbox Name="PageNumber">
    
    <CanGrow>true</CanGrow>
    
    <KeepTogether>true</KeepTogether>
    
    <Paragraphs>
    
    <Paragraph>
    
    <TextRuns>
    
    <TextRun>
    
    <Value>=Globals!PageNumber</Value>
    
    <Style />
    
    </TextRun>
    
    </TextRuns>
    
    <Style />
    
    </Paragraph>
    
    </Paragraphs>
    
    <rd:DefaultName>PageNumber</rd:DefaultName>
    
    <Top>0.34042in</Top>
    
    <Left>3.7675in</Left>
    
    <Height>0.25in</Height>
    
    <Width>1in</Width>
    
    <Style>
    
    <Border>
    
    <Style>None</Style>
    
    </Border>
    
    <PaddingLeft>2pt</PaddingLeft>
    
    <PaddingRight>2pt</PaddingRight>
    
    <PaddingTop>2pt</PaddingTop>
    
    <PaddingBottom>2pt</PaddingBottom>
    
    </Style>
    
    </Textbox>
    
    <Textbox Name="Textbox3">
    
    <CanGrow>true</CanGrow>
    
    <KeepTogether>true</KeepTogether>
    
    <Paragraphs>
    
    <Paragraph>
    
    <TextRuns>
    
    <TextRun>
    
    <Value>Generic Test Report for Brad</Value>
    
    <Style />
    
    </TextRun>
    
    </TextRuns>
    
    <Style />
    
    </Paragraph>
    
    </Paragraphs>
    
    <rd:DefaultName>Textbox3</rd:DefaultName>
    
    <Top>0.34042in</Top>
    
    <Left>0.44458in</Left>
    
    <Height>0.25in</Height>
    
    <Width>1.97917in</Width>
    
    <ZIndex>1</ZIndex>
    
    <Style>
    
    <Border>
    
    <Style>None</Style>
    
    </Border>
    
    <PaddingLeft>2pt</PaddingLeft>
    
    <PaddingRight>2pt</PaddingRight>
    
    <PaddingTop>2pt</PaddingTop>
    
    <PaddingBottom>2pt</PaddingBottom>
    
    </Style>
    
    </Textbox>
    
    </ReportItems>
    
    <Style>
    
    <Border>
    
    <Style>None</Style>
    
    </Border>
    
    </Style>
    
    </PageHeader>
    
    <LeftMargin>1in</LeftMargin>
    
    <RightMargin>1in</RightMargin>
    
    <TopMargin>1in</TopMargin>
    
    <BottomMargin>1in</BottomMargin>
    
    <Style />
    
    </Page>
    
    <rd:ReportID>48f5f7dc-e410-41fa-832d-454bf71e6e8c</rd:ReportID>
    
    <rd:ReportUnitType>Inch</rd:ReportUnitType>
    
    </Report>
    
    

    Brad Syputa, Microsoft Reporting Services This posting is provided "AS IS" with no warranties.
    Wednesday, June 30, 2010 8:54 PM
  • I tried to get around this by using report parameters, but that gave the same #Error.  I was finally able to work around this by adding a secondary dataset to the report in which the columns held the information that I wanted to show on the report (specifically, a meaningful report title). I blogged about how I got around this at http://saltydogllc.com/?p=299.
    Tuesday, July 13, 2010 10:01 PM
  • I've made a very simple report with:

    1) TextFiled with "CIAO" inside --> Shows up

    2) TextField with ReportName (built-in field) --> Gives #Error

    3) TextField with ExecutionTime (built-in field) --> Gives #Error

    Every time I use an expression for example: arithmetic operations between data fields or anything else I get the #Error in the ReportViewer.

    This is mysimple rdlc with 3 TextFields:

    I'm using the reportviewer control inside an ASP .NET page. (version 10.0.0....) ASP .NET 4.0

    <?xml version="1.0" encoding="utf-8"?>
    <Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">
     <Body>
      <ReportItems>
       <Textbox Name="Textbox2">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
         <Paragraph>
          <TextRuns>
           <TextRun>
            <Value>CIAO</Value>
            <Style />
           </TextRun>
          </TextRuns>
          <Style />
         </Paragraph>
        </Paragraphs>
        <rd:DefaultName>Textbox2</rd:DefaultName>
        <Top>0.78833in</Top>
        <Left>2.7675in</Left>
        <Height>0.25in</Height>
        <Width>1in</Width>
        <Style>
         <Border>
          <Style>None</Style>
         </Border>
         <PaddingLeft>2pt</PaddingLeft>
         <PaddingRight>2pt</PaddingRight>
         <PaddingTop>2pt</PaddingTop>
         <PaddingBottom>2pt</PaddingBottom>
        </Style>
       </Textbox>
      </ReportItems>
      <Height>2in</Height>
      <Style />
     </Body>
     <Width>6.5in</Width>
     <Page>
      <PageHeader>
       <Height>1in</Height>
       <PrintOnFirstPage>true</PrintOnFirstPage>
       <PrintOnLastPage>true</PrintOnLastPage>
       <ReportItems>
        <Textbox Name="ExecutionTime">
         <CanGrow>true</CanGrow>
         <KeepTogether>true</KeepTogether>
         <Paragraphs>
          <Paragraph>
           <TextRuns>
            <TextRun>
             <Value>=Globals!ExecutionTime</Value>
             <Style />
            </TextRun>
           </TextRuns>
           <Style />
          </Paragraph>
         </Paragraphs>
         <rd:DefaultName>ExecutionTime</rd:DefaultName>
         <Top>0.5175in</Top>
         <Left>5.16333in</Left>
         <Height>0.25in</Height>
         <Width>1in</Width>
         <Style>
          <Border>
           <Style>None</Style>
          </Border>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
         </Style>
        </Textbox>
        <Textbox Name="ReportName">
         <CanGrow>true</CanGrow>
         <KeepTogether>true</KeepTogether>
         <Paragraphs>
          <Paragraph>
           <TextRuns>
            <TextRun>
             <Value>=Globals!ReportName</Value>
             <Style />
            </TextRun>
           </TextRuns>
           <Style />
          </Paragraph>
         </Paragraphs>
         <rd:DefaultName>ReportName</rd:DefaultName>
         <Top>0.56958in</Top>
         <Left>2.31958in</Left>
         <Height>0.25in</Height>
         <Width>1in</Width>
         <ZIndex>1</ZIndex>
         <Style>
          <Border>
           <Style>None</Style>
          </Border>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
         </Style>
        </Textbox>
       </ReportItems>
       <Style>
        <Border>
         <Style>None</Style>
        </Border>
       </Style>
      </PageHeader>
      <LeftMargin>1in</LeftMargin>
      <RightMargin>1in</RightMargin>
      <TopMargin>1in</TopMargin>
      <BottomMargin>1in</BottomMargin>
      <Style />
     </Page>
     <rd:ReportID>bdfbcfd9-276c-41ab-9015-04c973fb0ddb</rd:ReportID>
     <rd:ReportUnitType>Inch</rd:ReportUnitType>
    </Report>
    
    Wednesday, July 14, 2010 1:53 PM
  • I've found two workarounds for this problem:

    1) Changing Target Framework from 4.0 to 3.5 in the project settings

    2) Adding the following line inside the web.config in the system.web section:

    <trust legacyCasModel="true" level="Full"/>
    • Proposed as answer by René N. _ Wednesday, July 14, 2010 3:00 PM
    Wednesday, July 14, 2010 2:26 PM
  • I have the same problem. I was able to trace down the thing that is causing it (at least in my case): if you set the roleManager tag in web.config to enabled=true the globals are not working. If you remove it, or set enabled=false it is working.

    Now, how is the roleManager connected with the ReportViewer I have no idea. Maybe someone could have some solution or workaround...

    Thursday, August 5, 2010 7:33 PM
  • This doesn't look like an RDL issue, can you send a copy our your web.config for a site that can repro the issue. Based on some follow up posts it appears to be related to the new CAS policy model in .NET 4 which causes the ReportViewer to execute expressions in a sandbox AppDomain, if you set <trust legacyCasModel="true" level="Full" /> it will force the ReportViewer expressions to run in the current AppDomain and should work around the issue. I'm investigating to see if I can repro the issue.

    Matt M.


    This posting is provided "AS IS" with no warranties, and confers no rights

    Friday, August 6, 2010 8:10 PM
  • Just create an empty site, add a .RLDC report with a Globals!PageNumber in the header, add one form with ReportViewer in it (don't forget to add ScriptManager) that displays the .RLDC. Then add the <roleManager enablet="true"></roleManer> within  system.web section of the web.config and start the page. You'll see the error. If you set enabled="false" the error dissapears. My web config is:

    <?

     

     

    xml version="1.0"?>

    <!--

    For more information on how to configure your ASP.NET application, please visit

    http://go.microsoft.com/fwlink/?LinkId=169433

     

     

     

    -->

    <

     

     

    configuration>

    <

     

     

    system.web>

    <

     

     

    httpHandlers>

    <

     

     

    add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

     

     

     

    validate="false" />

    </

     

     

    httpHandlers>

    <

     

     

    compilation debug="false" targetFramework="4.0">

    <

     

     

    assemblies>

    <

     

     

    add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

    <

     

     

    add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

    <

     

     

    add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

    <

     

     

    add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

    </

     

     

    assemblies>

    <

     

     

    buildProviders>

    <

     

     

    add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

    </

     

     

    buildProviders>

    </

     

     

    compilation>

    <

     

     

    roleManager enabled="true"></roleManager>

    </

     

     

    system.web>

    <

     

     

    system.webServer>

    <

     

     

    validation validateIntegratedModeConfiguration="false" />

    <

     

     

    handlers>

    <

     

     

    add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

    </

     

     

    handlers>

    </

     

     

    system.webServer>

    </

     

     

    configuration>

     

     Thanks in advance!

    Friday, August 6, 2010 8:20 PM
  • I've found two workarounds for this problem:

    1) Changing Target Framework from 4.0 to 3.5 in the project settings

    2) Adding the following line inside the web.config in the system.web section:

    <
    trust
     legacyCasModel
    =
    "
    true
    "
     level
    =
    "
    Full
    "
    />
    


    I was having the same problem getting #Error when displaying report parameters or built-in fields or Global fields (like page info).

    I used the #2 workaround adding legacyCssModel entry to my web config. Works like a charm!!

    Thank you Rene!!

    Wednesday, February 23, 2011 5:24 PM
  • Just these two lines will solve the problem completely: (It works on MVC projects too)

     

    System.Security.PermissionSet sec=new System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrestricted);

    ReportViewer1.LocalReport.SetBasePermissionsForSandboxAppDomain(sec);


    nioosha
    Thursday, November 3, 2011 6:27 AM
  • And when do not use a reportviewer and render the pdf directely.

     

            public ActionResult DetailsReport()
            {
                LocalReport localReport = new LocalReport();
                localReport.ReportPath = Server.MapPath("~/Content/Reports/CAEReport.rdlc");
                ReportDataSource reportDataSource = new ReportDataSource("CAEDataSet", CAERep.GetCAE());

                localReport.DataSources.Add(reportDataSource);
                string reportType = "PDF";
                string mimeType;
                string encoding;
                string fileNameExtension;

                //The DeviceInfo settings should be changed based on the reportType
                //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
                string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>PDF</OutputFormat>" +
                "  <PageWidth>21cm</PageWidth>" +
                "  <PageHeight>29.7cm</PageHeight>" +
                "  <MarginTop>1.5cm</MarginTop>" +
                "  <MarginLeft>1cm</MarginLeft>" +
                "  <MarginRight>0cm</MarginRight>" +
                "  <MarginBottom>1cm</MarginBottom>" +
                "</DeviceInfo>";

                Warning[] warnings;
                string[] streams;
                byte[] renderedBytes;

                //Render the report
                renderedBytes = localReport.Render(
                    reportType,
                    deviceInfo,
                    out mimeType,
                    out encoding,
                    out fileNameExtension,
                    out streams,
                    out warnings);

                //Response.AddHeader("content-disposition", "attachment; filename=CAE." + fileNameExtension);
                return File(renderedBytes, mimeType);

     

    Monday, January 9, 2012 5:40 PM
  • Another option:

    localReport.SetBasePermissionsForSandboxAppDomain(AppDomain.CurrentDomain.PermissionSet.Copy());

    See here for more information:

    http://stackoverflow.com/questions/6347125/reportviewer-2010-fails-to-evaluate-expressions/9638596#9638596

    We've noticed this problem only occurs when running the app from IIS. If we run from a unit test or the debugger the expressions work.

    • Edited by Brian L22 Friday, March 9, 2012 5:48 PM
    • Proposed as answer by Eric Selje Monday, May 13, 2013 3:34 PM
    Friday, March 9, 2012 5:45 PM
  • Thanks a lot. Rene

    It is awesome solution and exactly the root cause of the problem encountered after I upgraded my web application (that was written in older version: Visual Studio 2005, .Net Framework 2.0 and Report Version 8.0.0.0 into newer version: VS 2015, .Net Framework 4.6.2 and Report Version 12.0.0.0) due to the new CAS policy feature introduced in .Net framework 4.0 and above.


    • Edited by Be Lay Wednesday, June 28, 2017 3:39 PM
    Wednesday, June 28, 2017 3:33 PM