3

I have a VS2008 Web Application project that is being pre-compiled without being updatable. When I try to load a page that should display an RDLC report using the ReportViewer, it just displays an empty page. It works fine in a non-precompiled version. What could be the problem?

Daan
  • 6,952
  • 4
  • 29
  • 36
  • 1
    Asked and answered my own question, for future reference by myself and others who might run into the same problem. – Daan Sep 07 '10 at 07:31

4 Answers4

4

The problem is that VS also tries to compile the RDLC files, leaving only a marker file instead of the original .rdlc file. The ReportViewer cannot deal with this, and throws an error. This shows up in the logging as:

The report definition is not valid. Details: Data at the root level is invalid. Line 1, position 1.

The solution is to copy the original RDLC files to the deployed application. This can be automated in a post-build step. See also this thread for details on the error and this post on details how to edit the post-build step for a Web Deployment project. I added the following to my Web Deployment project file:

<ItemGroup>
  <ReportFiles Include="$(SolutionDir)Path\To\Reports\*.rdlc" />
</ItemGroup>
<Target Name="AfterBuild">
  <Copy SourceFiles="@(ReportFiles)" DestinationFolder=".\Release\Reports\" />
</Target>
Daan
  • 6,952
  • 4
  • 29
  • 36
  • This seems like an interesting topic, but there could be some better articles on it. I believe we're suggesting to unload the project, and then edit it adding similar to the above, correct? Confusing is that the publish profiles have the same schema, and almost seem like another target for such. – Greg Dec 01 '15 at 22:14
4

This solved the problem for me:

https://stephensonger.wordpress.com/2008/09/10/deploying-rdlc-files-in-local-mode-for-asp-net-applications/

That is, I removed the following from web.config and set the Build Action to Content:

<buildProviders>
    <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
  • Good find! As far as I can tell, `RdlBuildProvider` checks for invalid `.rdlc` files but does not transform/compile them. A solution I'm using is to remove the build provider for precompiled publish profiles with a [Web.config Transformation](https://learn.microsoft.com/previous-versions/dd465326(v=vs.100)) `` to continue checking the `.rdlc` files during other builds. – Kevinoid Jan 14 '22 at 15:58
  • Also, the link is no longer valid, but it can still be found in the Wayback Machine: https://web.archive.org/web/20130117055045/https://stephensonger.wordpress.com/2008/09/10/deploying-rdlc-files-in-local-mode-for-asp-net-applications/ – Kevinoid Jan 14 '22 at 16:00
1

Your answer didn't work for me. The following worked for me to copy files after the aspnet_compiler ran.

<Target Name="AdditionalFilesForPackage" AfterTargets="CopyAllFilesToSingleFolderForPackage;CopyAllFilesToSingleFolderForMsDeploy">
   <ItemGroup>
     <ExtraFiles Include="$(MSBuildProjectDirectory)\Path_To_Dir\**\*" />
   </ItemGroup>
   <Copy SourceFiles="@(ExtraFiles)" DestinationFiles="@(ExtraFiles->'$(_PackageTempDir)\Path_To_Dir\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
DeluxZ
  • 25
  • 5
0

This might not be the exact solution. I tried this in VS2013 and the precompilation is part of the publish-process, not build:

http://msdn.microsoft.com/en-us/library/hh475319(v=vs.110).aspx

Expand File Publish Options, and then select Precompile during publishing.

The post-build event runs before the publish / precompile process, so the .rdlc file is copied before it will (still) be precompiled. At least, it looks like this to me.

roberth
  • 924
  • 9
  • 17