Having searched a whole lot of similair posts, workarounds, I decided to make my own post.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0433:
The type
'Microsoft.Reporting.WebForms.ReportViewer'
exists in both
'c:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\reportmanager\Bin\ReportingServicesWebUserInterface.dll'
and
'c:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll'
Update:
Most similair posts have as a problem that their 2 conflicting DLLs have a version 8.0.0.0 and 9.0.0.0, or so. Or that they reside in the TEMPORARY folder. I do not think that my problem can be solved similairly with such posts.
On our ReportServer there exists a Report.aspx, which renders a report. I want to replace this file with my own, to modify the page layout, like so:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="WebApplication._Default" %>
<%@ Register
Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms"
TagPrefix="rsweb" %>
<!DOCTYPE>
<html>
<head runat="server"></head>
<body>
<div>
<form id="reportform" runat="server">
<div>
<rsweb:ReportViewer
ID='ReportViewerRoot'
runat='server'
ProcessingMode='Remote'
Height='100%'
Width='100%'
AsyncRendering='False'
SizeToReportContent='True'
/>
</div>
</form>
</div>
</body>
</html>
This requires a reference to MS.ReportViewer.WebForms.DLL
My Project.csproj file has this:
<Reference Include="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
I was not able to uninstall any DLLs in C:\WINDOWS, because it said it was required for other applications.
I have also tried to modify web.config, adding some dependentAssemnly, but not sure what would be useful (It was useful for version differences mentioned above).
Further I have these lines in web.config:
<compilation defaultLanguage="c#" debug="false" tempDirectory="C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\RSTempFiles\">
<assemblies>
<clear />
<add assembly="ReportingServicesWebServer" />
</assemblies>
</compilation>
Thank you for your input. I am looking forward to receiving your suggestions.
The satisfying solution!
When inserting a ReportViewer object in the aspx, the DLL reference is automatically added (and points to the GAC WebForms). I need this reference (Couldn't succeed manually referencing to GAC DLLs), then I remove the ReportViewer in the aspx. Also, I add the reference to the conflicting DLL ReportingServicesWebUserInterface.DLL. This moves the problem (error output from post) to VS, in stead of only on the SSRS Server.
When adding a new ReportViewer() I will get the error in VS.
The solution is as follows: give the none-required DLL an alias (without actually using it in code). This will tell the compiler that this DLL is not to be used when using WebForms. See picture
Report.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="MyWebApplication._Default" %>
<!DOCTYPE>
<html>
<head runat="server">
<title></title>
</head>
<body>
<div>
<div style="background-color:Red;width:100px;height:100px;">Hoi</div>
</div>
<form id="formID" runat="server">
test
</form>
<div>haha</div>
</body>
</html>
Report.aspx.cs
public partial class _Default : System.Web.UI.Page
{
ReportViewer ReportViewerRoot;
protected void Page_Load(object sender, EventArgs e)
{
AddRV();
}
public void AddRV()
{
ReportViewerRoot = new ReportViewer()
formID.Controls.Add(ReportViewerRoot);
SetReportViewer();
SetServerReport();
}
public void SetReportViewer()
{
ReportViewerRoot.ID = "ReportViewerRoot";
ReportViewerRoot.ProcessingMode = ProcessingMode.Remote;
}
private void SetServerReport()
{
ServerReport serverReport = ReportViewerRoot.ServerReport;
// Set the report server URL and report path
serverReport.ReportServerUrl = new Uri("http://localhost/reportserver");
serverReport.ReportPath = Request.QueryString["ItemPath"];
serverReport.Refresh();
}
}
Reference source: Extern alias walkthrough