Problem ze stroną (An unhandled exception)

0

Tam taki problem, który nie wiem jak rozgryźć. Mam stronkę, która sobie działa, ale kiedy korzystam z narzędzia do generowania sitemapy dla google (http://www.auditmypc.com/xml-sitemap.asp) pojawiają się problemy:

  1. Narzędzie nie może stworzyć sitemapy
  2. Po uruchomieniu narzędzia, na stronie pojawiają się błędy:

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.]
Index.BindData() +136
Index.Page_Load(Object sender, EventArgs e) +24
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627</span>

Kiedy sobie odświerzę stronę, pojawia się inny błąd:

Invalid attempt to call Read when reader is closed.
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.InvalidOperationException: Invalid attempt to call Read when reader is closed.

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:

[InvalidOperationException: Invalid attempt to call Read when reader is closed.]
System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) +640
System.Data.SqlClient.SqlDataReader.Read() +9
DowcipyDA.Szukaj(Dowcipy dowcip, String sortExpression, String sortOrder, Nullable1 count, Nullable1 pageIndex, Nullable1 numRows) +355 DowcipyBL.Szukaj(Dowcipy dowcip, String sortExpression, String sortOrder, Nullable1 count, Nullable1 pageIndex, Nullable1 numRows) +56
Index.BindData() +569
Index.Page_Load(Object sender, EventArgs e) +24
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627</span>

Znowu odświeżę i mam:

JokeCount
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.IndexOutOfRangeException: JokeCount

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:

[IndexOutOfRangeException: JokeCount]
System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) +4841162
System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +67
System.Data.SqlClient.SqlDataReader.get_Item(String name) +15
KategorieDA.CzytajDane(IDataReader reader) +262
KategorieDA.Szukaj(Kategorie kategorie) +132
KategorieBL.Szukaj(Kategorie kategoria) +5
myFantasies.BindData() +102
myFantasies.Page_Load(Object sender, EventArgs e) +394
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627</span>

Znowu odświeżę to znowu dostanę podobny błąd. Po ok. minucie, czy dwóch, wszystko wraca do normy, a strona działa. Gdzie mogłem zrobić błąd?

0

To sa bledy Twojej strony, czy strony generujacej sitemape? Jesli Twojej strony, to masz podane na tacy - 1 to zakladasz, ze jakis obiekt nie jest nullem, a jest. Drugi - czytasz z DataReadera po zamknieciu - moze zle obslugujesz readera i w wyniku pierwszego bledu reader po pierwsze istnieje, po drugie jest juz zamkniety, a Ty zakladasz, ze to nowy. 3 - indeks przekroczyl zakres tablicy - w kontekscie drugiego bledu tablica pewnie jest pusta(nic sie z bazy nie odczytalo), a wyswietlasz pierwszy dowcip.

1 użytkowników online, w tym zalogowanych: 0, gości: 1