ReportViewer in .Net 4 even possible? (legacyCasModel="true" causes problems) RRS feed

  • Question

  • I tried to put a simple report in a ReportViewer control in a .aspx page that is part of a MVC 3 / ASP.Net 4.0 site.

    Any expressions I had in the report didn't work (they just displayed "#ERROR" in the fields), and after some digging I came across a post telling me that in order to get the expressions to work with the new security model in .Net 4, that I had to set the following in my web.config:

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

    I did that and sure enough the report worked just great. An easy fix, joy!


    Unfortunately, I now get the following on all of my MVC views which use dynamic data types (which is pretty much all of them!):

     Dynamic operations can only be performed in homogenous AppDomain.

    And this error is obviously caused by my change to the change to the trust in the web.config, because if I remove that line then the views go back to working again.

    Does this basically mean that, at this point in time, using reports controls in .Net 4.0 websites is impossible and I need to run my reports out on a separate .Net 3.5 application, (or a separate .net 4.0 application that uses no dynamic types  - i.e. a site that does not use any of the wiz-bang stuff in MVC)?

    The Question:
    Has anyone been using reports with expressions in .aspx pages that are part of a MVC3 / ASP.Net 4.0 application?
    If so, can you describe the tricks you used to get it working?

    I am reminded lately why they call it "the bleeding edge". EF and MVC is very cool, but Linq to SQL, webforms, and 3.5 was always so much less painful!


    Monday, May 30, 2011 6:03 PM

All replies

  • Hi there,

    Did you ever find a workaround for this? I have the same issue trying to run ReportViewer with .NET4/MVC3 in Azure.




    Tuesday, October 18, 2011 8:02 PM
  • Local report processing requires full trust for an ASP.Net 4 site, at least if there are any expressions or parameters. Remote report processing (with the reports hosted on a SQL Server Report Services server) works in medium trust even for reports with expressions and parameters.
    Wednesday, October 19, 2011 11:45 AM
  • Thanks Paul,

    Doesn't Azure run in full trust by default, and therefore shouldn't I be fine using expressions and parameters?



    Thursday, October 20, 2011 1:36 AM
  • These two lines work well for me in MVC 3:
                System.Security.PermissionSet sec=new System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrestricted);
    I hope it helps.

    Sunday, November 6, 2011 4:49 AM
  • i have the same issue and this didnt help, i put them in the page_load but it is very slow, and i dont want to change the whole site putting it in the webconfig.
    Friday, May 29, 2015 9:13 PM
    • Proposed as answer by Pepepaco Friday, June 5, 2015 5:40 PM
    Friday, June 5, 2015 5:39 PM