Reputation: 24699
Our ASP.NET web application, which uses the Telerik RadGrid, 2.0.2.0, needs to be updated for Windows 7 compatibility. The issue is that the existing functionality to export an Excel file does not produce an Excel file that is compatible with Office 2007, which is part of our new Windows 7 set of common applications.
The issue is with these lines of code:
ExportXLS.Telerik.WebControls.RadGrid RadGrid1 = new
ExportXLS.Telerik.WebControls.RadGrid();
RadGrid1.MasterTableView.ExportToExcel(TableName, true, false);
We discovered that there is another dll, RadGrid.Net2 version 4.5.0.0, which includes a “ExportToExcel2007” method that is not available in the 2.0 version of the dll. This method does produce a valid Excel file that can be opened with Excel 2007.
Telerik.WebControls.RadGrid RadGrid1 = new Telerik.WebControls.RadGrid();
RadGrid1.MasterTableView.ExportToExcel2007(TableName, true, false);
The problem is that there appears to be drastic differences between the two dlls and switching over to use the new dll didn't look easy. Our intended solution was to reference both dlls in the application but use the newer one only in the screen that is having the problem with creating a 2007 compatible Excel file.
Using the following article as a guide,
http://blogs.msdn.com/b/ansonh/archive/2006/09/28/extern-alias-walkthrough.aspx
we made the following small changes:
Added a reference in the web project to "RadGrid.Net2.dll" and adjusted the alias property of this reference to "ExportXLS"
Add this to the top of the ExportExcel.aspx.cs code-behind page:
extern alias ExportXLS;
Then, instantiated a radgrid using the new dll by referring to the qualified reference of the radgrid.net2.dll:
ExportXLS.Telerik.WebControls.RadGrid RadGrid1 = new ExportXLS.Telerik.WebControls.RadGrid();
Modified the ExportToExcel method to use the 2007 counterpart method:
RadGrid1.MasterTableView.ExportToExcel2007(TableName, true, false);
This solved the issue with the ExportExcel.aspx page and the screen now produces a Excel 2007 compatible Excel spreadsheet, however, we were surprised that this change broke other pages in the application that uses RadGrid. This is the error:
c:\WINNT\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\7ff38b9a\2680aee3\App_Web_systemmapsearch.ascx.a97e7c59.tlmhafnf.0.cs(251): error CS0433:
The type 'Telerik.WebControls.GridRowIndicatorColumn'
exists in both
'c:\WINNT\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\root\7ff38b9a\2680aee3\assembly\dl3\cd8ec314\002177c0_d2e8cb01\RadGrid.DLL'
and
'c:\WINNT\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\7ff38b9a\2680aee3\assembly\dl3\428a2b2d\002177c0_d2e8cb01\RadGrid.Net2.DLL'
My expectation was that the other web pages would continue to use the unqualified older 2.0.2.0 version of the RadGrid.dll and would continue to work, but this is not the case.
Here is some of the code from the code behind of the user control, SystemMapSearch.ascx, that fails to load:
<%@ Register TagPrefix="radG" Namespace="Telerik.WebControls" Assembly="RadGrid" %>
<radg:radgrid id="RadGrid1" cssclass="RadGrid" runat="server" allowpaging="True" allowsorting="True" gridlines="none"
pagesize="20" width="100%" borderwidth="0" AutoGenerateColumns="False">
I have tried to change the NameSpace directive to include the global namespace, but this results in an invalid reference:
<%@ Register TagPrefix="radG" Namespace="global::Telerik.WebControls" Assembly="RadGrid" %>
Why does changing the ExportExcel.aspx page break the other pages and what do I have to do to fix the issue?
Upvotes: 3
Views: 2452
Reputation: 24699
I changed all occurrences of Assembly "Radgrid"
<%@ Register TagPrefix="radG" Namespace="global::Telerik.WebControls" Assembly="RadGrid" %>
to
<%@ Register TagPrefix="radG" Namespace="global::Telerik.WebControls" Assembly="RadGrid.Net2" %>
I think, until I made this change, it was still picking up the old radgrid.dll in the bin folder even though I no longer had a reference to the old radgrid.dll.
In any event, when I carely changed all occurences of the Assembly property everywhere and even deleted the old unused dll from the bin folder, it worked.
Upvotes: 1
Reputation: 4921
Hi maybe this stuff could help you resolve your problem.
For some reason, your application has loaded two different versions of the Telerik.Web.UI assembly. This is probably because you have both Telerik.Web.UI assemblies in the GAC.
To fix this problem you can go through your project and make sure that wherever you are referencing the Telerik.Web.UI assembly (in the web.config, or in an ASPX page) you are using the fully qualified assembly name. For example:
"Telerik.Web.UI, Version=2009.2.701.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
instead of just "Telerik.Web.UI". The fully qualified name includes the version number, so ASP.NET will not be confused into loading both assemblies at the same time. Reference:Compile Error Message: The type 'Telerik.Web.UI.RadFileExplorer' exists in both..
When upgrading existing telerik RadControls applications (which include RadChart) to RadControls for ASP.NET AJAX you may get the following error:
Error 1 The type 'Telerik.Charting. exists in both 'c:\WINDOWS\assembly\GAC_MSIL\Telerik.Charting...\Telerik.Charting.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files...\RadChart.Net2.DLL'
The reason for this error is because RadChart (3.x and later) and RadControls for ASP.NET AJAX Chart use shared code.he shared code is in the form of Telerik.Charting.dll assembly which is ILMerged in the RadChart.Net2.dll for backwards compatibility reasons and is shipped separately for RadControls for ASP.NET AJAX.
The error will manifest itself whenever you attempt to reference BOTH RadChart.Net2.dll and Telerik.Charting.dll.
There are two ways to resolve the issue:
Please have in mind that RadChart for ASP.NET AJAX and RadChart 4.x have 99% identical functionality. It is up to your personal preference to decide which one you would like to use. The most significant difference is the assembly name and the fact that RadChart for ASP.NET AJAX uses an HttpHandler to display images and RadChart 4.x still uses RadControls\Image.aspx for backwards compatibility reasons. Reference: Telerik.Charting. in both Telerik.Charting.dll and RadChart.Net2.dll
This is a generic error and usually means that there is a mismatch in your referenced assemblies and the actual ones used. Most likely you have side-by-side reporting installations and have mismatched references. Please use the Upgrade Wizard to upgrade your projects containing Telerik reports and rebuild them. If you have added manual references i.e. Copy Local = True, then delete all assemblies from the \bin folder, re-add proper references in the project and rebuild the project after that. If the problem still occurs make sure that you have specified the full assembly qualified name in each reference. For example:
<%@ Register assembly="Telerik.ReportViewer.WebForms, Version=5.0.11.328, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" namespace="Telerik.ReportViewer.WebForms" tagprefix="telerik" %>
as opposed to:
<%@ Register TagPrefix="telerik" Assembly="Telerik.ReportViewer.WebForms" Namespace="Telerik.ReportViewer.WebForms" %>
Reference: Telerik.Reporting.Report exists in both ....
Add the batch="false" attribute to the "compilation" element of the web.config file.
This problem occurs because of the way in which ASP.NET 2.0 uses the application references and the folder structure of the application to compile the application. If the batch property of the element in the web.config file for the application is set to true, ASP.NET 2.0 compiles each folder in the application into a separate assembly.
Reference: ASP.Net error: “The type 'foo' exists in both ”temp1.dll“ and ”temp2.dll"
Upvotes: 3
Reputation: 907
I've never actually done this, but I believe you could write a wrapper dll for the new Telerik dll, exposing only the needed functionality, and then reference the wrapper in your project.
Upvotes: 1
Reputation: 390
I ran into a similar problem in an old project i have worked on.
I know that deleting the temporary files fixed the problem as we were able to compile and deploy the web application (every feature worked as expected).
I didn't digg enough into why that kind of error showed up.
Upvotes: 2