LocalReport.Render seems to clear Thread.CurrentPrincipal.Identity since upgrading ReportViewer RRS feed

  • Question

  • Background - We've had in place for a number of years a form with a ReportViewer control for rendering local reports in our WinForm application.  Originally this was developed using ReportViewer version 8. This form utilizes similar (vb) code to the example on the page in the link below for printing directly to the printer (if a boolean is set) instead of previewing the report.

    We also use an application level authentication scheme that sets the Thread.CurrentPrincipal at login time and utilizes it throughout their application session to identify what areas they have permission to within the application.

    The problem - after upgrading our application to Framework 4.6.1 in VS 2015 and upgrading to ReportViewer Version 12 we've discovered that after calling LocalReport.Render(format,devideInfo,createStream,warnings) the Thread.CurrentPrincipal identity is lost.

    Here's the code snippet we used to identify where this was occurring:

    Debug.Print("Before render - Name: " & System.Threading.Thread.CurrentPrincipal.Identity.Name)
    Debug.Print("      Authenticated: " & System.Threading.Thread.CurrentPrincipal.Identity.IsAuthenticated)
    m_objStreams = New List(Of Stream)()
    objReport.Render(OUTPUT_FORMAT, sDeviceInfo, AddressOf CreateStream, objWarnings)
    Debug.Print("After render - Name:  " & System.Threading.Thread.CurrentPrincipal.Identity.Name)
    Debug.Print("      Authenticated: " & System.Threading.Thread.CurrentPrincipal.Identity.IsAuthenticated)

    The first 2 Debug.Print values contain the appropriate Identity values.  After calling the Render method, the Debug.Print Identity values show as a blank string for Name and IsAuthenticated=False.

    We did further testing with Version 11 of the ReportViewer and discovered the same issue there.  This all worked fine with version 8, so is there a new recommended way to accomplish this functionality in Version 11/12?

    Thanks in advance.


    • Edited by scgJohn Wednesday, March 30, 2016 9:17 PM
    Wednesday, March 30, 2016 9:14 PM

All replies

  • Clarification & Update

    To clarify, the upgrades to Framework 4.6.1 and ReportViewer 12.0 were done independently and I can confirm that the issue is caused by the upgrade from ReportViewer 8.0 to 12.0.

    Update - I had thought that perhaps the issue was because I was using the LocalReport object attached to the clients reportviewer control and somehow that UI object was causing the thread issue, however I've reworked to the code for the auto-print capability to be independent from the View/Print version.

    We've also done additional ReportViewer version testing to determine where the issue was introduced:

    • Version 8 - works correctly (no loss of CurrentPrincipal.Identity)
    • Version 9 -  works correctly...
    • Version 10 - Loses Identity
    • Version 11 - Loses Identity
    • Version 12 - Loses Identity

    Friday, April 1, 2016 5:52 PM
  • Hi, I am having the same trouble over here.

    Have you found a solution to this problem yet?

    We've been talking to MS help line for a while but just narrowed down our problem is one you described above.

    Wednesday, January 25, 2017 2:45 PM
  • Did anyone ever find an answer to this? I have the same problem with .NET 4.5 and ReportViewer 11. 

    Thursday, August 24, 2017 2:14 PM
  • Was this ever resolved?  I am seeing identity being lost intermittently with the latest ReportViewer as well....
    Sunday, October 20, 2019 10:40 PM
  • Are you still having the issue?
    Sunday, October 20, 2019 10:42 PM