object reference not set to an instance of an object

Ask a Question related to ASP.NET, Design and Development.

  1. #1

    Default object reference not set to an instance of an object

    My code is posted below. I am getting the error shown in the subject
    on the last line that does the Replace method. I've verified that the
    hidden field exists on the form itself.

    I am not sure why this is happening.

    Any help would be appreciated.

    -Tim

    string strCreateView;
    protected HtmlInputHidden hdnOrigCreateView;

    //create the view for the search
    strCreateView = "CREATE VIEW #Test AS ";
    strCreateView += "SELECT FileIndex, DocTitle, vpath, filename, size,
    write, characterization, rank ";

    strCreateView += "FROM SCOPE(' DEEP TRAVERSAL OF ( " + strScope + " )
    ')";

    //store the create view statement in the form
    //replace all quotes with its ascii equivalent
    hdnOrigCreateView.Value = strCreateView.Replace("\"", """);
    Tim Guest

  2. Similar Questions and Discussions

    1. Dynamically loading user control into Placeholder gives Object reference not set to an instance of an object
      I've created user controls that contain listboxes that are dynamically populated from the database. In the html view of the user control...
    2. Custom Control Problem :: Object reference not set to an instance of an object
      Hi All! I have the following Custom Control file... '########### WebUserControl1.ascx ############# <%@ Control Language="vb"...
    3. [WebMethod] System.NullReferenceException: Object reference not set to an instance of an object.
      Um, this isn't going to work, generally. Web services, as any web app (especially on Windows server 2003) are heavily sandboxed. The method you...
    4. Mysterious Error: Object reference not set to an instance of an object
      Hi There! I'm having a mysterious error right after I login using Forms Authentication in my ASP.NET app. Below is the error... Exception...
    5. HELP! Error Loading ASPX : Object Reference not set to an instance object
      Hello, When i run my aspx i get this weird error: System.NullReferenceException: Object reference not set to an instance of an object. at...
  3. #2

    Default Re: object reference not set to an instance of an object

    Is the hidden field set to runat="server"? If not, then that is why you are
    getting that. Also, not only does it have to be set to runat server, it also
    has to be declared in the code-behind.

    HTH,

    Bill P.

    "Tim" <tim.cavins@sitel.com> wrote in message
    news:dc9a9e04.0307170746.6c43d184@posting.google.c om...
    > My code is posted below. I am getting the error shown in the subject
    > on the last line that does the Replace method. I've verified that the
    > hidden field exists on the form itself.
    >
    > I am not sure why this is happening.
    >
    > Any help would be appreciated.
    >
    > -Tim
    >
    > string strCreateView;
    > protected HtmlInputHidden hdnOrigCreateView;
    >
    > //create the view for the search
    > strCreateView = "CREATE VIEW #Test AS ";
    > strCreateView += "SELECT FileIndex, DocTitle, vpath, filename, size,
    > write, characterization, rank ";
    >
    > strCreateView += "FROM SCOPE(' DEEP TRAVERSAL OF ( " + strScope + " )
    > ')";
    >
    > //store the create view statement in the form
    > //replace all quotes with its ascii equivalent
    > hdnOrigCreateView.Value = strCreateView.Replace("\"", "&quot;");

    Bill Priess Guest

  4. #3

    Default Object reference not set to an instance of an object

    Hi,

    I have a web service which was running perfectly fine under my dev
    machine running win xp PRO and under our test server running win 2k.
    But since last week service stopped working on server. Everytime I call
    it I get above error. I asked server guys if they installed anything in
    last week, they say no. Does anyone know of any obvious difference
    between win 2k and XP pro?

    Jaydeep

    Jay Guest

  5. #4

    Default Re: Object reference not set to an instance of an object

    Could be one of the million ways you could get that error. The best way is
    to ask for debug permissions on the machine, and see where your code is
    breaking.

    --
    Manohar Kamath
    Editor, .netWire
    [url]www.dotnetwire.com[/url]


    "Jay" <jay30_shah@yahoo.com> wrote in message
    news:1111037542.530183.173340@z14g2000cwz.googlegr oups.com...
    > Hi,
    >
    > I have a web service which was running perfectly fine under my dev
    > machine running win xp PRO and under our test server running win 2k.
    > But since last week service stopped working on server. Everytime I call
    > it I get above error. I asked server guys if they installed anything in
    > last week, they say no. Does anyone know of any obvious difference
    > between win 2k and XP pro?
    >
    > Jaydeep
    >

    Manohar Kamath Guest

  6. #5

    Default Re: Object reference not set to an instance of an object

    I did find the error. Code was failing exactly at connection.Open()
    method. The error was cleared up (with no change in code) by resetting
    IIS. My question is, how did this happen?, is there any known issue
    with connection.Open() method or oracle connection pool to cause this
    error? Right now error is gone but I am worried if it will happen again
    and how frequently.

    Jay
    Manohar Kamath wrote:
    > Could be one of the million ways you could get that error. The best
    way is
    > to ask for debug permissions on the machine, and see where your code
    is
    > breaking.
    >
    > --
    > Manohar Kamath
    > Editor, .netWire
    > [url]www.dotnetwire.com[/url]
    >
    >
    > "Jay" <jay30_shah@yahoo.com> wrote in message
    > news:1111037542.530183.173340@z14g2000cwz.googlegr oups.com...
    > > Hi,
    > >
    > > I have a web service which was running perfectly fine under my dev
    > > machine running win xp PRO and under our test server running win
    2k.
    > > But since last week service stopped working on server. Everytime I
    call
    > > it I get above error. I asked server guys if they installed
    anything in
    > > last week, they say no. Does anyone know of any obvious difference
    > > between win 2k and XP pro?
    > >
    > > Jaydeep
    > >
    Jay Guest

  7. #6

    Default Object reference not set to an instance of an object

    Hi
    Any idea what's happening, please?! TIA, details.....

    I have a formA.aspx page and a corresponding class file formA.cs compiled
    into a library. User is to fill out some information and click a submit
    button to trigger a click event. Here is what I have in formA.cs

    public Button btnSubmit

    protected override void OnInit(EventArgs e)
    {
    btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
    }
    void btnSubmit_Click(Object sender, EventArgs e)
    {
    String domain, str_path, objName;
    //code to create obj
    if (IsValid) {
    ...
    try
    {
    DirectoryEntry myDir = new DirectoryEntry(str_path);
    ...
    }
    catch (Exception Exception1)
    {
    System.Runtime.InteropServices.COMException COMEx =
    (System.Runtime.InteropServices.COMException)Excep tion1;
    //ConsoleWriteline(COMEx.ErrorCode);
    }

    //code to add UPN

    //code to create LDAP files
    }
    }
    ------
    Here is the Stack trace
    [NullReferenceException: Object reference not set to an instance of an
    object.]
    NETDS.ouCreate.btnOUCreate_Click(Object sender, EventArgs e) +38
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

    System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePo
    stBackEvent(String eventArgument) +57
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
    sourceControl, String eventArgument) +18
    System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
    System.Web.UI.Page.ProcessRequestMain() +1292


    --



    Guest

  8. #7

    Default Re: Object reference not set to an instance of an object

    The error is in btnOUCreate_Cli*ck event. Need to see that code

    BillGatesFan Guest

  9. #8

    Default Re: Object reference not set to an instance of an object

    Sorry, please see my other post ( Subject: ...... - newpost) TIA

    "BillGatesFan" <klj_mcsd@hotmail.com> wrote in message
    news:1115695125.473044.62560@f14g2000cwb.googlegro ups.com...
    The error is in btnOUCreate_Cli*ck event. Need to see that code


    Guest

  10. #9

    Default Re: Object reference not set to an instance of an object

    Sorry, please see my other post ( Subject: ...... - newpost) TIA

    "BillGatesFan" <klj_mcsd@hotmail.com> wrote in message
    news:1115695125.473044.62560@f14g2000cwb.googlegro ups.com...
    The error is in btnOUCreate_Cli*ck event. Need to see that code


    Guest

  11. #10

    Default RE: Object reference not set to an instance of an object

    What are u trying to do exactly?


    "dl" wrote:
    > Hi
    > Any idea what's happening, please?! TIA, details.....
    >
    > I have a formA.aspx page and a corresponding class file formA.cs compiled
    > into a library. User is to fill out some information and click a submit
    > button to trigger a click event. Here is what I have in formA.cs
    >
    > public Button btnSubmit
    >
    > protected override void OnInit(EventArgs e)
    > {
    > btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
    > }
    > void btnSubmit_Click(Object sender, EventArgs e)
    > {
    > String domain, str_path, objName;
    > //code to create obj
    > if (IsValid) {
    > ...
    > try
    > {
    > DirectoryEntry myDir = new DirectoryEntry(str_path);
    > ...
    > }
    > catch (Exception Exception1)
    > {
    > System.Runtime.InteropServices.COMException COMEx =
    > (System.Runtime.InteropServices.COMException)Excep tion1;
    > //ConsoleWriteline(COMEx.ErrorCode);
    > }
    >
    > //code to add UPN
    >
    > //code to create LDAP files
    > }
    > }
    > ------
    > Here is the Stack trace
    > [NullReferenceException: Object reference not set to an instance of an
    > object.]
    > NETDS.ouCreate.btnOUCreate_Click(Object sender, EventArgs e) +38
    > System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
    >
    > System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePo
    > stBackEvent(String eventArgument) +57
    > System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
    > sourceControl, String eventArgument) +18
    > System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
    > System.Web.UI.Page.ProcessRequestMain() +1292
    >
    >
    > --
    >
    >
    >
    >
    Patrick.O.Ige Guest

  12. #11

    Default Object reference not set to an instance of an object

    Hello I got the following error message:

    Object reference not set to an instance of an object.
    6/27/2006 9:17:02 AM Stack trace:
    at MySql.Data.MySqlClient.PacketWriter.WriteStringNoN ull(String v)
    at MySql.Data.MySqlClient.MySqlCommand.PrepareSqlBuff ers(String sql)
    at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader( CommandBehavior
    behavior)
    at
    MySql.Data.MySqlClient.MySqlCommand.System.Data.ID bCommand.ExecuteReader(Com
    mandBehavior behavior)
    at System.Data.Common.DbDataAdapter.FillFromCommand(O bject data, Int32
    startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
    CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
    startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
    CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
    srcTable)
    at Fact.TestConnect.connect2DB() in
    c:\Inetpub\wwwroot\Fact\TestConnect.cs:line 114
    Cycle finished



    My source code close to the error look like this:

    DataSet milestones = new DataSet();
    foreach(string sl in serviceLevelList) {
    Console.WriteLine(sl);
    MySqlDataAdapter adapter = new MySqlDataAdapter(
    "SELECT From Table where x='y'", dest.Connection);
    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
    adapter.MissingMappingAction = MissingMappingAction.Passthrough;
    adapter.Fill(milestones, sl); <- error occurs



    milestones and sl are not null. has anyone an clue what might help?

    thanks in advance!!

    best regards,

    Dennis


    Dennis Kuntzemann Guest

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139