Problem with Microsoft Report on Terminal Server


SSRS Login failed for unattended execution account


> Start > All Programs > Reporting Services Configuration Manager

> Connect

> Execution Account

> Put in new Account + Password

LocalReport set-up and publish

How do I … keep reports in a sub-directory

May be set in code or in ReportViewer control

Dim report as New LocalReport()
report.ReportPath = “Reports\ReportName.rdlc”

How do I … fix Local reports that work in Visual Studio not when published

The errors you may get include:

  • An error occurred during local report processing copy
    The report definition for report ‘..\some_path_to_report\<reportname>.rdlc’ has not been specified
    Could not find file ‘C:\inetpub\wwwroot\some_path_to_report\tse.rdlc’.

When reports are added their default Build Action is Embedded Resource.
To fix this change to Content and choose a copy policy, probably Copy if Newer

How do I … use a report in a referenced project

Add the report as a “Linked” file ( Add existing item > Add as Link )(probably) at the same directory level as in the referenced project
Then on these linked files choose the necesary options as above

How do I … directly printing a project report.rdlc in VB.Net without previewing first

Also see next blog entry


  1. Imports System
    Imports System.IO
    Imports System.Data
    Imports System.Text
    Imports System.Drawing
    Imports System.Drawing.Imaging
    Imports System.Drawing.Printing
    Imports System.Collections.Generic
    Imports System.Windows.Forms
    Imports Microsoft.Reporting.WinForms
  2. Load data as usual
  3. Dim report as New LocalReport
    report.ReportPath = “<ReportName>.rdlc”
    report.ReportPath = “Reports\<ReportName>.rdlc
    report.DataSources.Add(New ReportDataSource(“dtRouteCardWO”, CType(Me.DsRouteCard1.RouteCardWO, DataTable)))
  4.     Private Sub Export(ByVal report As LocalReport)
            ‘MsgBox(“Start of Export”)   ‘Reaches this line on EBC Rise TS
            ‘then before “End of Export” get “Error occurred during local report processing”        Dim deviceInfo = “<DeviceInfo>” & _
                “<OutputFormat>EMF</OutputFormat>” & _
                “<PageWidth>8.3in</PageWidth>” & _
                “<PageHeight>11.7in</PageHeight>” & _
                “<MarginTop>0.25in</MarginTop>” & _
                “<MarginLeft>0.25in</MarginLeft>” & _
                “<MarginRight>0.25in</MarginRight>” & _
                “<MarginBottom>0.25in</MarginBottom>” & _
            Dim warnings As Warning() = Nothing
            m_streams = New List(Of Stream)()

            ‘See my blog. For this to work the Build Action must be changed from Embedded Resource to Content and a Copy policy chosen
            ‘For this to work from a different project. Add this file as a link in that project and then do above on linked file.
            report.Render(“Image”, deviceInfo, AddressOf CreateStream, warnings)
            For Each stream As Stream In m_streams
                stream.Position = 0

            ‘MsgBox(“End of Export”)
        End Sub

  5.     Private Function CreateStream(ByVal name As String, ByVal fileNameExtension As String, ByVal encoding As System.Text.Encoding, ByVal mimeType As String, ByVal willSeek As Boolean) As Stream
            Dim stream As Stream = New MemoryStream()
            Return stream
        End Function
  6.     Private m_currentPageIndex As Integer
        Private m_streams As IList(Of Stream)
  7.     ‘ Handler for PrintPageEvents
        Private Sub PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
            Dim pageImage As New Metafile(m_streams(m_currentPageIndex))        ‘ Adjust rectangular area with printer margins.
            Dim adjustedRect As New Rectangle(ev.PageBounds.Left – CInt(ev.PageSettings.HardMarginX), _
                                              ev.PageBounds.Top – CInt(ev.PageSettings.HardMarginY), _
                                              ev.PageBounds.Width, _

            ‘ Draw a white background for the report
            ev.Graphics.FillRectangle(Brushes.White, adjustedRect)

            ‘ Draw the report content
            ev.Graphics.DrawImage(pageImage, adjustedRect)

            ‘ Prepare for the next page. Make sure we haven’t hit the end.
            m_currentPageIndex += 1
            ev.HasMorePages = (m_currentPageIndex < m_streams.Count)
            ev.HasMorePages = False ‘#1074 srs fudge. Routecard was on 2 pages, should always be 1
        End Sub

        Private Sub Print()
            ‘MsgBox(“Start of Print”)
            If m_streams Is Nothing OrElse m_streams.Count = 0 Then
                Throw New Exception(“Error: no stream to print.”)
            End If
            Dim printDoc As New PrintDocument()
            If Not printDoc.PrinterSettings.IsValid Then
                Throw New Exception(“Error: cannot find the default printer.”)
                AddHandler printDoc.PrintPage, AddressOf PrintPage
                m_currentPageIndex = 0
            End If
            ‘MsgBox(“End of Print”)
        End Sub

  8.     Public Shadows Sub Dispose() Implements IDisposable.Dispose
            If m_streams IsNot Nothing Then
                For Each stream As Stream In m_streams
                m_streams = Nothing
            End If
        End Sub


  1. An error occurred during local report processing copy
    The report definition for report ‘..\some_path_to_report\<reportname>.rdlc’ has not been specified
    Could not find file ‘C:\inetpub\wwwroot\some_path_to_report\tse.rdlc’.
  2. Could not find file ‘C:\inetpub\wwwroot\some_path_to_report\tse.rdlc’.

VB.Net or SSRS code for Ordinal Numbers

Easily found on web. See example in SRS.ReportingServices.Functions and also in my invoice report.
With acknowledgement to:

Public Function FormatOrdinal(day as Integer) As String
  SELECT CASE (day Mod 100)
    CASE 11,12
    CASE 13
      Return day.ToString() + “th”

  SELECT CASE day Mod 10
    Case 1
      Return day.ToString() + “st”
    Case 2
      Return day.ToString() + “nd”
    Case 3
      Return day.ToString() + “rd”
    Case Else
      Return day.ToString() + “th”
End Function

Good luck!

SSRS Adding Code and also custom assemblies to reports

How to add Code to SSRS reports

  1. Right click on report > Code > Type code as Visual Basic function
  2. In expressions within a data region use Code.<functionname> e.g. =Code.OrdinalFunction(4)

Code for Ordinal Number readily avialable on web. Example use in SRS.ReportingServices.Functions and also in my invoice report

How to add custom assemblies to SSRS reports

  1. Create a class library project in Visual Studio VB.Net or C#
  2. Use a meaningful assembly name e.g. <initials>.ReportingServices.Functions
  3. Add a class and methods to this class. Make the methods shared
  4. Compile to create a dll
  5. Copy the dll to the equivalent location of:
    C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies
    You may not need the (x86) and you may be on a lower or higher version than 9.0
  6. In VS BIDS report right click > report properties > References > Add the reference
  7. In expressions in a report use full Namespace.ClassName.FunctionName(variables)

Next deploying the assembly to the report server

  1. Copy your DLL to the following location or equivalent:
    C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin

Good luck. Acknowledgments to:

SSRS open url in a new window

With thanks to:

=”javascript:void(‘”+ Fields!ReferURL.Value + “‘,’_blank’))”


SSRS Data Cache in Development

After some effort I found that data in SSRS Development environment was being cached in a files called <ReportName>
So you may be expecting data to change and finding that it is not. To get around this you can do one of the following:

The following error may be due to this cache of data
[rsInvalidExpressionDataType] The Value expression used in textrun ‘InvoiceTitle.Paragraphs[0].TextRuns[0]’ returned a data type that is not valid.

Good luck!

SSRS Subscriptions – Email – Windows File Share

So easy does not need much detail here.
My publish on a schedule to either a file share or by email.
To use Email settings need to set up in SSRS configuration of server.

Subscriptions cannot be created because the credentials used to run the report are not stored, or if a linked report, the link is no longer valid.

The report credentails were Windows Authentication. For my scenario it was feasible to save low read-only credentials with the report.

SQL Server Report Manager takes a long time to start up

See post below
May need to go to Programs > turn windows features on or off for IIS Manager

I believe the setting you are looking for is the “Shutdown worker processes
after being idle for…” on the Performance tab of the application pool that
the Reports virtual directory is assigned to.
See old post below for details:
[quoted text, click to view]


If you are running Windows 2003 server for your IIS reportserver, then this
is a simple issue – I’ll explain what happens:
The report service engine, once it is idle for more than the default 20
minutes, the worker process is shutdown.
This is controlled by IIS.
Open up the Internet Information Services (IIS) Manager
Expand the server node then the application pools.
On my IIS machine, I created an application pool dedicated to the
reportserver & reportmanager virtual webs.
But anyways, for the application pool that the reportserver is pointing to
if you left everything to their defaults will be the DefaultAppPool.
Right click the default app pool and select properties.
There are two things that are checked by default – On the recycling tab
there is a checkbox for recycling worker processes – it is currently set to
1740 minutes (29 hours). Leave it.
The other one is on the performance tab – which is the one you are
interested in changing….
See the “Idle Timeout” section and increase the number of minutes to be 8
hours a typical working day – 8*60 = 480 minutes.
Next, to be sure the “morning person” that runs the first report doesn’t get
the delay, set up a schedule for either a dummy or adhoc report to fire off
like at 6am so that the report component worker processes get loaded.