ReportViewer build issues in VS2010

I am using ReportViewer 10.0.0.0 from VisualStudio2010 in my web application and I am having problems with its builds. ReportViewer 8.0.0.0 and 9.0.0.0 are installed on the server, and I'm trying to avoid installing version 10.0.0.0.

I thought it was possible to use the ReportViewer10 DLL on the server, even if it is not installed. I set the Build Action property for dlls in Content to copy them to the output bin folder. The Copy to Output Directory property is Do not copy .

As the following error shows, my project finds two assemblies from ReportViewer, one in the GAC and the other in Temporary ASP.NET Files . Search, I also found that Temporary ASP.NET Files re-generates every request to the server.

Trying to solve my problem, I removed the dll from Temporary ASP.NET Files , and the whole application stopped working, showing that my application used the dll from Temporary ASP.NET Files , and not from the GAC or bin folder. I want my application to use the dll from the bin folder or Temporary ASP.NET Files , because in these places the dll is in the correct version (10.0.0.0). The following error shows a conflict between ReportViewer9 DLL from GAC DLL and ReportViewer10 from Temporary ASP.NET Files .

 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. CS0433: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both 'c:\\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\project\4ec9147f\d072b522\assembly\dl3\662a86a1\009c93d3_afeccc01\Microsoft.ReportViewer.WebForms.DLL' Line 180: Line 181: [System.Diagnostics.DebuggerNonUserCodeAttribute()] Line 182: private global::Microsoft.Reporting.WebForms.ReportViewer @__BuildControlReportViewer1() { Line 183: global::Microsoft.Reporting.WebForms.ReportViewer @__ctrl; Line 184: Source File: C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\project\4ec9147f\d072b522\App_Web_default.aspx.cdcab7d2.dmkwuxko.0.cs Line: 182 
+4
source share
1 answer

My problem was resolved by following these steps:

I left dll links to my project, but I deleted them from the bin folder. Thus, the dll ceases to be regenerated in the Temporary ASP.NET Files folder, ending the conflict:

  CS0433: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both 'c:\\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\project\4ec9147f\d072b522\assembly\dl3\662a86a1\009c93d3_afeccc01\Microsoft.ReportViewer.WebForms.DLL' 

The report viewer did not work as expected (the GAC only had versions 8 and 9 of the DLL). Then, Report Viewer 10.0.0.0 was installed on the server, and this time a new error appeared:

  CS0433: The type 'Microsoft.Reporting.WebForms.ReportViewer' exists in both 'c:\\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\9.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' and 'c:\\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\10.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll' 

It seemed strange to me that this conflict occurred between different versions of the DLL, and this time the solution was to add the following tag to the web.config file:

  <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50727"> <dependentAssembly> <assemblyIdentity name="Microsoft.ReportViewer.WebForms" publicKeyToken="b03f5f7f11d50a3a"/> <bindingRedirect oldVersion="9.0.0.0" newVersion="10.0.0.0"/> </dependentAssembly> </assemblyBinding> 

Done. It worked without any conflicts, and it was possible to export reports.

My problem has been resolved, but I still have one doubt, and I hope someone helps me with this:

Why did the server have a conflict between two dlls from GAC_MSIL in different versions? Shouldn't the server only look at the version specified in my project and specified in Web.config? (10.0.0.0)

Does the machine.config file relate to?

+6
source

Source: https://habr.com/ru/post/1398207/


All Articles