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
I resolve my problem
To Remove the One Assembly from my Web.Config
In My Case Version 10 and 11 is comes together.
I Remove below code from by Config
<add assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
Also a reason this may occur is if you have nested applications. ie. App2 inside of App1.
App1's web.config might mess with App2's. Make sure that they don't reference different versions of the same Assembly.
Not in this answer, but in the next answer I have put the satisfactory solution!! :)
This very solution does work too but is not satisfying concerning the development-cycle/readability/maintainability.
My Report.aspx file contains nothing but this line:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Report.aspx.cs" Inherits="WebApplication._Default" %>
My Report.aspx.cs does contain code such as:
HtmlGenericControl body = new HtmlGenericControl();
HtmlForm form = new HtmlForm();
ReportViewerRoot = new ReportViewer();
Controls.Add(body);
body.Controls.Add(form);
form.Controls.Add(ReportViewerRoot);
My ReportManager/Web.config contains additional tags as:
<!-- added enableSessionState -->
<pages validateRequest="false" enableSessionState="true" />
<httpModules>
<clear />
<!-- added -->
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
</httpModules>
<httpHandlers>
<!-- added -->
<add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpHandlers>
P.s.:
In no way I am able to combine html-code in report.aspx with a reportviewer (neither aspx or cs).
Nor can I add the ReportViewer dynamically in the aspx by using <% AddRV(); %>
P.s.s.
The Web.config helped me solve these errors:
In remote mode, the Report Viewer control requires session state be enabled or Report Server connection information specified in the
config file.
The Report Viewer Web Control HTTP Handler has not been registered in the application's web.config file. Add to the system.web/httpHandlers
section of the web.config file.
Go to
HKEY_CLASSES_ROOT\Installer\Assemblies\Global
search for the assembly and delete complete row by right click over that and choose delete.
Includes in web.config a tag dependentAssembly to force the specific version:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.ReportViewer.WebForms" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>