Object reference not set to an instance of an object.

Feb 18, 2009 at 5:24 PM
When I click on the ExportToExcel Button I get the following error:


Server Error in '/xxxxxxx' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   KrishLabs.Web.Controls.ExportToExcel.ExportToExcel_OnClick(Object Sender, EventArgs e) +28
   KrishLabs.Web.Controls.ExportToExcel.ExportToExcel_Click(Object sender, EventArgs e) +30
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   KrishLabs.Web.Controls.ExportToExcel.RaisePostBackEvent(String eventArgument) +45
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

Code on Page:


<rk:exporttoexcel id="ExportToExcel1" runat="server" applystyleinexcel="True" charset="utf-8"



contentencoding="windows-1250" enablehyperlinks="True" includetimestamp="True" pagesize="All"



text="Export To Excel" />



<!--Author: Rajesh K, Copyright 2007 All rights reserved. Use this control at your own risk. Author is not responsible for any defects or damages to your code.-->


VB Code on Code-Behind Page:



Protected Sub ExportToExcel1_PreExport(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExportToExcel1.PreExport



Dim CurrMonth As Int16


CurrMonth = Month(Now())


Dim pId As Int16


pId = 3

loadGrid(pId, CurrMonth)

ExportToExcel1.ExportFileName =







End Sub




Feb 22, 2009 at 1:27 PM
Can you verify your "Bin" folder and check if you see "ExportToExcel.dll" ?