.NET Logo
Welcome Guest Search | Active Topics | Members | Log In | Register

Error แบบนี้หมายความว่าอย่างไรครับ ช่อวยทีครับ Options · View
offsign
Posted: Wednesday, October 08, 2008 9:17:16 AM
Rank: มือสมัครเล่น
Groups: Member

Joined: 9/3/2008
Posts: 27

 

 

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.]
   CH.Button3_Click(Object sender, EventArgs e) +126
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   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

 

Server Error in '/nitisakp/cs' Application.

Object reference not set to an instance of an object.

 


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

blankbrain
Posted: Wednesday, October 08, 2008 3:10:05 PM

Rank: มือสมัครเล่น
Groups: Member

Joined: 9/26/2008
Posts: 26
Location: BKK

น่าจะเกิดจากการ instantiate ลองดูว่ามี xx = new Panel() ใน public void xxx(xx){} หรือไม่ หากมีให้ย้ายไปที่ public xxxx() แทนครับ

offsign
Posted: Thursday, October 09, 2008 9:43:28 AM
Rank: มือสมัครเล่น
Groups: Member

Joined: 9/3/2008
Posts: 27

ช่วยอธิบายอีกหน่อยได้ไหมครับ ลองยกตัวอย่างก็ได้ครับ พอดีเพิ่งหัดเขียนอะครับ เลยไม่ค่อยเข้าใจ

blankbrain
Posted: Thursday, October 09, 2008 11:34:27 AM

Rank: มือสมัครเล่น
Groups: Member

Joined: 9/26/2008
Posts: 26
Location: BKK

NullReferenceException เป็นเออเรอของการไปอ้างอิงถึง Method ,Property ,member ของตัวแปรออบเจ็กต์ที่ยังไม่ได้ชี้ไปยังออบเจ็กต์จริงๆ (ตัวแปรที่เป็น null) ยกตัวอย่างเช่น การประกาศตัวแปรแล้วไม่ได้กำหนดค่าเริ่มต้นหรือกำหนดเป็น null ต้องประกาศแบบนี้ครับ

string aaa="";

//not use string aaa =null;

แต่ผมไม่แน่ใจว่าจะตรงกับเออเรอที่ส่วนไหนของโค้ดคุณเนื่องจากไม่เห็นโค้ดตอนนี้แค่สันนิษฐานครับ

ลองบั้กค่า line  CH.Button3_Click(Object sender, EventArgs e) +126 ดูเบื้องต้นก่อนครับครับ โดย Watch ดูว่า ตัวไหนเป็น null ซึ่งหากเป็นค่าว่างจะบอก <undefined value> ครับ
 

offsign
Posted: Thursday, October 09, 2008 11:47:50 AM
Rank: มือสมัครเล่น
Groups: Member

Joined: 9/3/2008
Posts: 27

ขอบคุณมากครับ คือผมลองๆดูแล้ว และลองทดสอบแล้วครับ คือ ดวลาทดสอบที่เครื่องผมเองจะไม่มีปัญหาอะไร แค่พอไปลองที่ server มันจะเป็นแบบนั้นครับ ลองทดสอบแล้ว มันเกิดจาก Session ที่ผมกำหนดอะครับพอเวลามันไปที่ server แล้วมันเกิดเป็นค่าว่างอะครับ ทุกตัวเลย คือผมดึงข้อมูลจากฐานข้อมูลมาเก็บ ในSession อะครับ แต่เวลาที่ลองในเครื่องก็ไม่เห็นมีปัญหาเกิดจากอะไรหรอครับ รอคำชี้แนะครับ

 

blankbrain
Posted: Thursday, October 09, 2008 11:58:10 AM

Rank: มือสมัครเล่น
Groups: Member

Joined: 9/26/2008
Posts: 26
Location: BKK

ไม่ทราบว่าบน server file web.config มีการคอนฟิกเก็บ session เป็นแบบใดเหมือนกับlocal หรือปล่าวครับ เพราะปกติมีสามแบบ คือ

  1. InProc (default mode)  เป็นการเก็บใน memory
  2. State Server เป็นการเก็บในเครื่งซึ่งสามารถแชร์ข้ามเครือ่งได้ ตัวอย่าง
    <configuration>
      <system.web>
        <sessionState mode="StateServer"
          stateConnectionString="tcpip=SampleStateServer:42424"
          cookieless="false"
          timeout="20"/>
      </system.web>
    </configuration>
  3. SQL Server เป็นการเก็บในดาต้าเบสเซิร์ฟเวอร์ ตัวอย่าง
    <configuration>
      <system.web>
        <sessionState mode="SQLServer"
          sqlConnectionString="Integrated Security=SSPI;data 
            source=SampleSqlServer;" />
      </system.web>
    </configuration>

 

Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.


Sponsored by