.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Post New Web Links

Help with Object reference not set to an instance of an object. error.

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
 
I was given a chunk of code to help with accessing dynamic forum controls about a week back and when I implemented the code I get the error "Object reference not set to an instance of an object". I asked in the thread the code was given but have not recived an answer yet (asked about 4 days ago) and I think that is beause  the thread is marked as resolved. The line of code  causing the error is   if(t.Equals(this.ddlAmountToAdd.ClientID)&&!string.IsNullOrEmpty(v))    And here is the full code for the c# .Net 4 page.using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class GameInformation_AddUpcomingRelease : System.Web.UI.Page { public string[] Regions = { "USA", "Japan", "Europe", "Other" }; //Create a string array of regions. public string[] Platforms = { "PlayStation 3", "X-Box 360", "Wii", "Computer", "PSP", "Other" }; //Create a string array of platforms. protected void Page_Load(object sender, EventArgs e) { ddlPlatform1.DataSource = Platforms; ddlPlatform1.DataBind(); ddlRegion1.DataSource = Regions; ddlRegion1.DataBind(); } protected override void OnInit(EventArgs e)


View Complete Post


More Related Resource Links

Object reference not set to an instance of an object error.

  
i've installed the VSeWSS.msi on VS 2005, i'm using SPS 2007, i'm developing on my workstation in C#, i've added the Mircosoft.Sharepointserver dll reference to my project but i still can't deploy a very basic webpart. i get the "Object reference not set to an instance of an object" error but there's no reference to a line, column, project or anyhting. very frustrating. any suggestions/links whould be appreciated.

Login error - Object reference not set to an instance of an object.

  
Hi all,I've set up the login section as a user control. WheneverI log in I get a "Object reference not set to an instance of an object", with the code stopping on this line: if (Membership.ValidateUser(txtUserName.Text,txtPassword.Text))Can anyone tell me how to fix this please?protected void LoginButton_Click(object sender, EventArgs e) { TextBox txtUserName = loggedin.FindControl("UserName") as TextBox; TextBox txtPassword = loggedin.FindControl("Password") as TextBox; CheckBox ckbRememberMe = loggedin.FindControl("RememberMe") as CheckBox; if (Membership.ValidateUser(txtUserName.Text,txtPassword.Text)) { FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, ckbRememberMe.Checked); } else { // Msg.Text = "Login failed. Please check your user name and password and try again."; } } <asp:LoginView ID="loggedin" runat="server"> <AnonymousTemplate> <asp:Login ID="Login1" runat="server"> <LayoutTemplate> <table id="mainbox" width="400"> <tr> <td width="150" class="label">

Error while export to pdf-Object reference not set to an instance of an object

  
Hello, I am getting error while rendering the report to pdf in SSRS 2008. This is happening randomly and sometimes I get this error. I have SQL Server 2008 SP1 installed in my system . I installed the cumulative update 1 for SP1 also but no luck. Every time when export to pdf fails, SSRS is creating the dump file in the logs. I have captured the log of this specific error. Please let me know if you have any idea about this.   reportrendering!ReportServer_0-297!1ec4!03/30/2010-10:32:57:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.UnhandledReportRenderingException: An error occurred during rendering of the report., ; Info: Microsoft.ReportingServices.ReportProcessing.UnhandledReportRenderingException: An error occurred during rendering of the report. ---> Microsoft.ReportingServices.OnDemandReportRendering.ReportRenderingException: An error occurred during rendering of the report. ---> System.NullReferenceException: Object reference not set to an instance of an object.   at Microsoft.ReportingServices.Rendering.HPBProcessing.Paragraph.get_SpaceBefore()   at Microsoft.ReportingServices.Rendering.RichText.LineBreaker.FlowParagraph(Paragraph paragraph, Directions direction, IntPtr hdc, Single dpiX, FontCache fontCache, FlowContext flowContext, Boolean keepLines, SizeF flowContextSize, Int32& contentOffset)   at Mi

Configure managed accounts - object reference not set to an instance of an object - error

  
I was working in central admin and activated the managed accounts password change for the farm account with the option to change the password now.  I got the email notification that the password was changed and it seems in the log files that it did update all the credentials that were used with the account.  Problem is now that when I hit the configure managed accounts link in central admin all I get is the error: Error Object reference not set to an instance of an object.  Troubleshoot issues with Microsoft SharePoint Foundation. Correlation ID: c6dc7a46-894f-4b85-8711-8af1e8ec7903 Date and Time: 8/23/2010 9:20:20 AM Added information from logs: 08/23/2010 10:41:33.24  w3wp.exe (0x0F2C)                        0x07FC SharePoint Foundation          Logging Correlation Data       xmnv Medium   Name=Request (GET:http://cmtcalcium:33333/_admin/ManagedAccounts.aspx) b9fae5a9-7405-407d-87fc-239dc0ff59d0 08/23/2010 10:41:33.24  w3wp.exe (0x0F2C)                        0x07FC SharePoint Foundation     &n

Giving me an error "Object reference not set to an instance of an object."

  
Hello Everyone, I am currently developing a website for online examination.  For that I have to collect user information at the time of registration. I want to develop a 3-tier application. I have SignUpWizard. Aspx page. I have also created 3 classes (Users.cs, UserDAL.cs and UserBAL.cs) and 1 stored procedure (InsertUserInfo).Code for Users.cs:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Configuration; using System.Data.SqlClient; using System.Web.Security; using System.Data; namespace ITIL.DomainModels { public class Users { public int UserID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Username { get; set; } public string Password { get; set; } public string EmailAddress { get; set; } public string dateTime { get; set; } public string IPAddress { get; set; } public string SecurityQuestion { get; set; } public string SecurityAnswer { get; set; } } }Code for UserDAL.cs:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Data.SqlClient; using System.Configuration; using ITIL.DomainModels; namespace ITIL.DAL { public class UserDAL { publi

SqlCommand error: "Object reference not set to an instance of an object."

  

 Hi all,

I am not sure what's wrong with this block of code:

  • protected void FillDataGridView(string timeStamp)   
  • {   
  •  string select = "exec Uds.Dashboard_GetJobs";   
  •  string connectionString = WebConfigurationManager.ConnectionStrings["UctConnectionString"].ConnectionString;            
  •  SqlDataSource sourceRealtimeLogging = new SqlDataSource(connectionString, select);   
  •   
  •  SqlCommand cmd = new SqlCommand();   
  •  cmd.CommandType = CommandType.StoredProcedure;   
  •  cmd.Parameters.Add(new SqlParameter("@date", SqlDbType.DateTime));   
  • error:Object reference not set to an instance of an object.

      

    i set the drop down list value in page load .i ll change the value of it and once i click button the value must be displayed.but error is popped out in drop down list in button click event



    public partial class edit : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {
            string degree1; string id1;

            ArrayList AlDay = new ArrayList(); AlDay.Add("SELECT THE GENDER");

            AlDay.Add("F"); AlDay.Add("M");
            DropDownList1.DataSource = AlDay;
            
        
          

                id1 = "";
                degree1 = Request.QueryString["degree"];
                id1 = Request.QueryString["name"];

                if (!IsPostBack)
            &n

    Error: Object reference not set to an instance of an object for an array in vb.net

      

    I have the following code

    Dim ls_case_no() As String = Nothing
     Dim li_case_count As Integer = 0
    
      Dim li_case As String = ""
             li_case = xmlLocNode.InnerText
                                                If Not li_case = "" Then
                                                    'li_case = li_case.Replace("-", "")
                                                    ls_case_id = li_case
    
    
                                                    ReDim Preserve ls_case_no(li_case_count)
                                                    li_case_count = li_case_count + 1
                                                    ls_case_no(li_case_count - 1) = ls_case_id
                                                End If
    
     myNode = xmlLocNode.SelectSingleNode("nc:CaseTrackingID", nsMgr)
                                                 If Not myNode.InnerText = "" Then
                                                    Dim li_case As String = myNode.InnerText
                                                   lbl_caseno.Text = li_case
                                                    ls_case_core = li_case
                                                End If
    
     If Not ls_case_no.Length = 0 Then
                For d = 0 To ls_case_no.Length - 1
                    If Not ls_case_no(d) = ls_case_core Then
                         lb

    Add Users: Error - Object reference not set to an instance of an object

      
    Hi

    For some reason I can no longer access to the Add User or Add Group pages under session Site Actions => Site Settings => People and Groups. Due to this I can't add / remove users from Site. The same error observing in all the sites. The error message I get is Object reference not set to an instance of an object (Please find the error message below). Can anyone help please?


    Error Message:
    Object reference not set to an instance of an object.   at Microsoft.SharePoint.SPRoleDefinitionCollection.Init()
       at Microsoft.SharePoint.SPRoleDefinitionCollection.Undirty()
       at Microsoft.SharePoint.SPBaseCollection.System.Collections.IEnumerable.GetEnumerator()
       at Microsoft.SharePoint.ApplicationPages.AclInv.InitPage()
       at Microsoft.SharePoint.ApplicationPages.CBaseAclPage.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


    (S.O.S) Help: Object reference not set to an instance of an object Error!!!

      

    Hi,

    I'm getting the following error from Visual studio 2008 each time i debug my C# application:

      Message="Object reference not set to an instance of an object."
      Source="App_Code.jd_hrfuq"
      StackTrace:
           at ShoppingCartAccess.get_shoppingCartId() in d:\FURNITURE WEBSITE\ASPNETEcommerce\16\BalloonShop\App_Code\ShoppingCartAccess.cs:line 28
           at ShoppingCartAccess.GetItems() in d:\FURNITURE WEBSITE\ASPNETEcommerce\16\BalloonShop\App_Code\ShoppingCartAccess.cs:line 187
         &n

    "Object reference not set to an instance of an object" error occurs when trying to edit or open a na

      

    I'm going through the MS SQL Server SSIS Step by Step book from Microsoft Press and I think I have an issue with my install of MS SQL Server.  On the first exercise, the book instructs you to open an existing project and then open a data source view from the project.  The data source view contains several table objects and a named query object.  When I right-click on the named query object and then choose 'Edit Named Query .', I get a pair of 'Object reference not set to an instance of an object' errors.  This also happens if I double-click on the object itself.

     

    I created a blank project.  Then I created a Data Source View and populated it with tables from an existing database using the wizard.  When I tried to add a new named query I got the same error.

     

    Is there a configuration error here?  So far all of the other functions have worked normally.

     

    SQL Server 2005 Developer - SP2 (all patches applied) (SQL Server 2005 Evaluation exhibits the same error)

    <

    stsadmin error: "Object reference not set to an instance of an object"

      

    Hi,

    I have made a standard single server MOSS installation. Everything appears to be working fine, but I get errors when using stsadm to add solutions. (i.e. the Application Template Core, part of the server admin templates - http://www.microsoft.com/downloads/details.aspx?FamilyId=C1039E13-94DA-4D7D-8CAE-3B96FA5A4045&displaylang=en).

    Running i.e. "stsadm -o addsolution -filename ApplicationTemplateCore.wsp" gives the following error:

    Object reference not set to an instance of an object. ApplicationTemplateCore.wsp: The Solution installation failed.

    I get the excact same error, when I try to deploy Solutions using VSEWSS (November CTP).

    Any ideas to solve this would be greatly appreciated.

     

    Regards,

    Thomas N. Sørensen


    Error in MS SMS on Modify some triggers, "Object reference not set to an instance of an object"

      

    I've recently had to re-install "SQL 2005 SMS SP3 Update12" and now have a very bizzare situation. My OS is Win XP Pro SP3 and on top of the SQL Stuff I also have Visual Studio 2008 and DevX tools.

    The basic situation is that when I right click on a trigger and choose 'Modify" or any 'script to' options I get:

    • "Object reference not set to an instance of an object. (Microsoft.SqlServer.Smo)"
    • Program Location: 
         at Microsoft.SqlServer.Management.Smo.DependencyTreeNode..ctor(Int32 index, DependencyChainCollection siblings)
         at Microsoft.SqlServer.Management.Smo.DependencyTreeNode.get_FirstChild()
         at Microsoft.SqlServer.Management.Smo.DependencyWalker.WalkDependentChildren(DependencyTree tree, DependencyTreeNode depParent, DependencyCollection depList)
         at Microsoft.SqlServer.Management.Smo.DependencyWalker.WalkDependentChildren(DependencyTree tree, DependencyTreeNode depParent, DependencyCollection depList)
         at Microsoft.SqlServer.Management.Smo.DependencyWalker.WalkDependencies(DependencyTree tree)
         at Microsoft.SqlServer.Management.Smo.Scripter.Script(Urn[] urns, SqlSmoObject[] objects)
         at Microsoft.SqlServer.Management.Smo.Scripter.Script(SqlSmoObject[] obje

    Error loading and running event receiver: Object reference not set to an object instance

      

    I'm getting the following error for my client's SharePoint production server.

    Error loading and running event receiver myproject.Receivers.ListItem.ContentApprovalEventHandler in ..., Version=1.0.0.0, Culture=neutral, PublicKeyToken=.... Additional information is below.  : Object reference not set to an object instance.    

     

    I know there are few posts already out there explaining the problem but I've not got the one matching my situation. The event receiver is working on dev and staging server but not on production. Few points I can mention here:

    1. My event receiver is not calling. I have put a log at the very beginning of the receiver and put the whole event receiver code in try/catch block. In catch block I have thrown a custom error. So if my code would be executed then the custom error would be in log file.

    2. The same event receiver is working on development and staging server.

    3. Production is a farm whereas dev and staging server is standalone.

    4. The production farm has two severs one of which is not configured properly.

    5. I have tested with code and made sure the event receiver is registered with the list.

     

    Apparently the problem might be permission/configuration related. Does anyone have any idea what might be the cause?

     

    Registering controls of current assembly object reference NOT set error

      

    Hi There,

    I have created a simple ASP.net Web Application (2.0) and have added a web user control.

    Now in my page I have added this control but I have registered like this,

    <%@ Register Assembly="WebApplication1" Namespace="WebApplication1" TagPrefix="Custom" %>

    Which means I want to access all the controls in my current Web Application project

    Then I have added my user control like this,

    <Custom:MyUserControl ID="MyUserControl1" runat="server" PublicProperty="Hello" />

    Every thing is fine but when I execute the project, NO control on my user control gets "instantiated" and thus I receive error "Object Reference Not Set"

    Note that My Control has,

    1) Public property PublicProperty as String

    2) 1 Label control

    In Load Event Handler I am setting Text property of Label Control to PublicProperty. Here object reference NOT set error occurs (which means Label control is NOT initialized).

    I don't want to register my control using Src, TagPrefix etc. Any ideas?

    Thanks


    FileUpload error: Object reference error

      

    I have a FormView with a FileUpload to upload an image in a database.

    I keep getting an object reference error.(view code)

    I am using this same script to upload the image to the database, but when I try to update the file upload I get the error.    



    string strFilePath=Server.MapPath("\\images\\"+fupdImage.FileName);

            Byte[] image=null;
            HttpPostedFile imgVid=FileUpload.PostedFile;

            image=new Byte[imgVid.ContentLength];//Object reference not set to an instance of an object.
            imgVid.InputStream.Read(image,0,imgVid.ContentLength);

            if(FileUpload.HasFile) {
            string imageFile=FileUpload.PostedFile.FileName;
            int index=imageFile.LastIndexOf(".");
            string fileFormat=imageFile.Substring(index+1);
            fileFormat=fileFormat.ToLower();

            if(fileFormat=="gif"||fileFormat=="jpg"
        &nb

    VS2010 Silverlight 4 - Getting "Object reference not set to an instance of an object" when loading a

      
    In Visual Studio 2010 I'm trying to use the Blacklight Controls (http://blacklight.codeplex.com/releases/view/37652) in my own project (and actually included the Blacklight.Controls project in my solution so that I could debug what was going on) and... after making all the XAML changes needed to incorporate the Blacklight navigation menu with my stuff in the innermost grid... everything compiled ok when doing a Build.  When I run it there's a reference to a resource dictionary in the XAML that fails with the object reference error above.  The XAML is as follows:       <UserControl.Resources>       <controls:ResourceDictionaryManager x:Key="ResourceDictionaryManager">       <controls:ResourceDictionaryManager.ResourceDictionaries>       <controls:ResourceDictionaryCollection>       <controls:ResourceDictionary Path="/Blacklight.Showcase;component/ResourceDictionaries/DavesGlossyControls.xaml">       <controls:ResourceDictionary.ResourceKeys>       <controls:ResourceKeyCollection>       <controls:ResourceKey ResourceName="GlossyBlackScrollViewer" />       </controls:ResourceKeyCollection>     &
    Categories: 
    ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
    Sql Server  SharePoint  Silverlight  Others  All   

    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend