Question

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?

Was it helpful?

Solution

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>

OTHER TIPS

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>

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.

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top