ASP.NET - namespace excel utility already contians function DatasettoExcel error

Asked By mani on 16-Jun-12 12:24 AM
hi i am using below code to download data in excel format..but some time only i am getting error as
namespace excel utility already contians function DatasettoExcel error but i am having only one function ..any help please??

namespace ExcelUtility

    public class DataSetToExcel
      public DataSetToExcel()
        // TODO: Add constructor logic here
      public static void Convert(DataSet ds, HttpResponse Response)

        Response.Charset = "";
        HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Cablist.xls"));
        Response.ContentType = "application/";
        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
        System.Web.UI.WebControls.DataGrid dg = new System.Web.UI.WebControls.DataGrid();
        dg.DataSource = ds.Tables[0];

Vikram Singh Saini replied to mani on 16-Jun-12 01:00 AM
I believe (as per my knowledge) that the problem might be because of creation of temporary files in C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files (could be different based on version).

For example, if you are testing the website or web application via VS IDE. And also you have hosted the same website on IIS, then there will be creation of two different dll's with same name in the same above mentioned folder, based on website's name.

This sometimes causes compiler to warn you or show error to you  for same because of conflict issues. Clean all temporary files from that folder. And after hosting the website on IIS, do not compile the website from VS IDE.

Hope this helps.
Jitendra Faye replied to mani on 18-Jun-12 07:23 AM
Yes, This is because of same function name already exist in namespace.

First Use "Find in Files" - "Entire Solution" and search the code, maybe another page have the same name.