RunTime Error: Type X exists in both VersionOne.dll and VersionTwo.dll
Our ASP.NET web application which uses Telerik RadGrid 2.0.2.0 needs to be updated to be compatible with Windows 7. The problem is that the existing functions for exporting an Excel file do not create an Excel file compatible with Office 2007 which is part of our new set of common Windows 7 apps.
The problem is with these lines of code:
ExportXLS.Telerik.WebControls.RadGrid RadGrid1 = new
ExportXLS.Telerik.WebControls.RadGrid();
RadGrid1.MasterTableView.ExportToExcel(TableName, true, false);
We found that there is another dll, RadGrid.Net2 version 4.5.0.0, which includes the ExportToExcel2007 method, which is not available in dll 2.0. This method actually creates an 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 seem to be major differences between the two dlls and switching to using the new dll doesn't seem easy. Our intentional solution was to reference both dlls in the application, but use the newer one only on the screen, which has a problem creating an Excel 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 link in the web project to "RadGrid.Net2.dll" and corrected the alias property of this link to " ExportXLS "
-
Add this at the top of the ExportExcel.aspx.cs code page:
extern alias ExportXLS ;
-
Then the radgrid is instantiated using the new dll, referencing the qualified reference radgrid.net2.dll:
ExportXLS .Telerik.WebControls.RadGrid RadGrid1 = new ExportXLS .Telerik.WebControls.RadGrid ();
-
Changed ExportToExcel method to use partner 2007 method:
RadGrid1.MasterTableView. ExportToExcel2007 (TableName, true, false);
This resolved the issue on the ExportExcel.aspx page and now the Excel Excel compatible Excel spreadsheet appears on the screen, however, we were surprised that this change broke other pages in the application using RadGrid. This is mistake:
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'
I expected other web pages to continue to use the unqualified version 2.0.2.0 of RadGrid.dll and continue to work, but this is not the case.
Below is the code of the code under the control of the custom control SystemMapSearch.ascx that is not loaded:
<%@ 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 tried changing 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 other pages and what should I do to fix the problem?
source to share
Hi, maybe this material will help you solve your problem.
-
For some reason, your application has loaded two different versions of the Telerik.Web.UI assembly. This is likely due to the fact that you have both Telerik.Web.UI assemblies in the GAC.
To fix this issue , you can go through your project and ensure that wherever you reference the Telerik.Web.UI assembly (in the web.config file or in the ASPX page) you are using the fully qualified name of the assembly. For example:
"Telerik.Web.UI, Version = 2009.2.701.20, Culture = neutral, PublicKeyToken = 121fae78165ba3d4"
instead of "Telerik.Web.UI". The fully qualified name includes the version number, so ASP.NET will not be confused with loading both assemblies at the same time. Ref: Compile Error Message: Type "Telerik.Web.UI.RadFileExplorer" exists as in ..
-
When updating existing telerik RadControls applications (including RadChart) for RadControls for ASP.NET AJAX, you may receive the following error:
Error 1 Type "Telerik.Charting. Exists in both cases: c: \ WINDOWS \ assembly \ GAC_MSIL \ Telerik.Charting .. . \ Telerik.Charting.dll 'and' c: \ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727 \ ASP.NET Temporary Files ... \ RadChart.Net2.DLL '
The reason for this error is that RadChart ( 3.x and later) and RadControls for ASP.NET AJAX Chart share code.The common code is in the form of the Telerik.Charting.dll assembly, which is ILMerged in RadChart.Net2.dll for backward compatibility and is shipped separately for RadControls for ASP .NET AJAX The error will show up whenever you try to reference BOTH RadChart.Net2.dll and Telerik.Charting.dll.
There are two ways to solve the problem:- If you are migrating your projects to use RadControls for ASP.NET AJAX, you can first remove the Telerik.Charting.dll reference from your Web.config file. In this case, you will be using the old ASP.NET diagram and you will not need the Telerik.Charting.dll that comes with the package. Telerik.Charting.dll is NOT required for ASP.NET AJAX controls other than Chart to work.
- If you are already using RadChart for ASP.NET AJAX, you will need to remove the reference to RadChart.Net2.dll and continue using Telerik.Charting.dll
Please keep in mind that RadChart for ASP.NET AJAX and RadChart 4.x has 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 HttpHandler to display images, while RadChart 4.x still uses RadControls \ Image.aspx for backward compatibility. Link: Telerik.Charting. in both Telerik.Charting.dll and RadChart.Net2.dll
- If you are migrating your projects to use RadControls for ASP.NET AJAX, you can first remove the Telerik.Charting.dll reference from your Web.config file. In this case, you will be using the old ASP.NET diagram and you will not need the Telerik.Charting.dll that comes with the package. Telerik.Charting.dll is NOT required for ASP.NET AJAX controls other than Chart to work.
-
This is a common mistake and usually means that your referenced assemblies and the actual ones are using inconsistencies. Chances are you have side-by-side reporting and have inappropriate links. Use the Refresh Wizard to refresh your projects containing Telerik reports and rebuild them. If you added the references manually, i.e. copy Local = True, then remove all assemblies from the \ bin folder, re-add the corresponding references to the project and rebuild the project after that. If the problem still occurs, make sure you include the fully qualified assembly name in each link. For example:
<% @ Assembly Registration = "Telerik.ReportViewer.WebForms, Version = 5.0.11.328, Culture = neutral, PublicKeyToken = a9d7983dfcc261be " namespace = "Telerik.ReportViewer.WebForms" tagprefix = "telerik "%>
unlike:
<% @Register TagPrefix = "telerik" Assembly = "Telerik.ReportViewer.WebForms" Namespace = "Telerik.ReportViewer.WebForms"%>
Reference: Telerik.Reporting.Report exists as in ... -
Add the batch = "false" attribute to the "compilation" element of the web.config file.
This issue occurs because of the way ASP.NET 2.0 uses application references and the application folder structure to compile the application. When the package property in the web.config file for an application is set to true, ASP.NET 2.0 compiles each folder in the application into a separate assembly.
Ref: ASP.Net Error: "Type" foo "exists in both" temp1.dll "and" temp2.dll "
source to share
I changed all occurrences of the "Radgrid" assembly
<%@ Register TagPrefix="radG" Namespace="global::Telerik.WebControls" Assembly="RadGrid" %>
to
<%@ Register TagPrefix="radG" Namespace="global::Telerik.WebControls" Assembly="RadGrid.Net2" %>
I guess until I made this change it was still collecting the old radgrid.dll file in the bin folder, even though I no longer had a link to the old radgrid.dll file.
Anyway, when I carefully changed all occurrences of the Assembly property everywhere and even removed the old unused dll from the bin folder, it worked.
source to share