473,769 Members | 6,739 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error - Object reference not set to an instance of an object.

OS Name Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 2 Build 2600
Total Physical Memory 1,024.00 MB

MDE 2003 Version 7.1.3008
..NET Framework 1.1 Version 1.1.4322 SP1
Microsoft Visual C# .NET 69462-335-0000007-18707
Crystal Reports for Visual Studio .NET AAP50-GS0000S-WCK00C3

I use an event handler as follows:

private ArrayList WTGData_10 = new ArrayList();
private void WTGDataRowReady 10Handler( WTGDataGroup_10 myWTGData )
{
WTGData_10Timer .Enabled = false;
try
{
WTGData_10.Add( myWTGData);
}
catch( Exception ex)
{
WriteToEventLog s.logWrite("WTG DataRowReady10H andler: " +
ex.Message, Utility.Trilliu mConstants.WTGL og);
}
WTGData_10Timer .Interval = 9999;
WTGData_10Timer .Enabled = true;
}

There may by 50 + calls to the handler on a ten minute event timer. The
handler stuffs the struct (WTGDataGroup_1 0 myWTGData) into the collection
myWTGData.

Once the timer WTGData_10Timer times out the following timer event handler
(onCalcTimedEve nt) trys to send the data to a SQL Database. The error occurs
in the following code while trying to equate myWTGData =
(WTGDataGroup_1 0)WTGData_10[i].

Note: The firct call to onCalcTimedEven t works fine - the records are
successfully written to the SQL database. All subsequent calls result in the
Object reference error.

public void onCalcTimedEven t(object source, ElapsedEventArg s e)
{
// local struct storage
WTGDataGroup_10 myWTGData = new WTGDataGroup_10 ();

// WTGData_10 is the collection that has been filled by the event handler
// Add each row from the collection WTGData_10 to the data set

// get a copy of the first row
myWTGData = (Trillium.WindS pace.WindSpace. WTGDataGroup_10 ) WTGData_10 [0];
// add it to the empty DS10MinData
DS10MinData.Cle ar();
addData(myWTGDa ta);

// add the rest, checking that there are no dups
for(int i = 1; i < WTGData_10.Coun t; i++)
{
bool bDupFlag = false;
try
{
//*********Error occurs here*********** ********
myWTGData = (WTGDataGroup_1 0)WTGData_10[i];
foreach ( DataRow DR in DS10MinData.Tab les "Turbine10Minut eData"].Rows)
{
// test if myWTGData row equals anything already in the Dataset DS10MinData
if ( (myWTGData.Turb ineID == Convert.ToInt32 (DR["Turbine ID"]))
&& (myWTGData.Turb ineCircuitID == Convert.ToInt32 (DR["Circuit ID"])) &&
(myWTGData.dt == Convert.ToDateT ime(DR["Date"])) )
{
//yes this myWTGData has a duplicate in the data set - don't add it
bDupFlag = true;
break;
}
}
}
catch( Exception ex)
{
//*************** ***ERROR handled here *****
WriteToEventLog s.logWrite("onC alcTimedEvent: testing for dups error: " +
ex.Message, Utility.Trilliu mConstants.WTGL og);
}
// if this is not a duplicate add it to the Data set
if ( !bDupFlag ) addData(myWTGDa ta);
bDupFlag = false;
// go on to the next element in the collection WTGData_10
}

// send the dataset to the data base
try
{
#region "SQL stuff"
// code not shown
#endregion
adpTurbine10Min Data.Update(DS1 0MinData);
adpTurbine10Min Data.Dispose();
}
catch( SqlException ex)
{
WriteToEventLog s.WTGLogWrite(
"WTGCube-onCalcTimedEven tonCalcTimedEve nt-Can't write to to TrilliumWind Db,
SQL Exception -" + ex.Message);
}

// remove all elements for the DS and the collection
DS10MinData.Cle ar();
WTGData_10.Clea r();
}
Nov 17 '05 #1
0 3558

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1206
by: Michael Chong | last post by:
I have an (exe) executable program created in VB.NET 2003 that calls to a MFC DLL written in VC++.NET 2003. I always get an error msg "NullReferenceException: Object Reference Not Set to an Instance of an Object" when my exe calls the following codes: in VB.NET Declare Function test Lib "C:\Cyob\IOComm\Debug\IOComm.dll" _ (ByVal a As Long, ByRef b As Integer) As Integer
1
2832
by: Chris Magoun | last post by:
I suddenly received an unexpected error in my project. I have been working on this project for some time without this issue. Nothing has changed in the form that caused the exception. A little experimentation shows that I cannot run ANY .NET web project without getting this error: ---------------------------------------------------------------------------- ---- Object reference not set to an instance of an object.
6
6126
by: blash | last post by:
Can someone help me? I really don't have a clue. My company staff told me they often got such error: "Object reference not set to an instance of an object." when they are in search result page then tried to access 2nd, or 3rd, etc page. The problem is it happens sometimes - sometimes when they clicked refresh button, then everything is ok. Now they told me it happens more frequently. but I have tried by myself many times and never got...
3
1741
by: Web Team | last post by:
Server Error in '/netapps' 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...
18
28758
by: Microsoft | last post by:
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object" Dim g As System.Drawing.Graphics g.DrawString("Test", New Font("Arial", 12, FontStyle.Bold), Brushes.Black, 0, 0) Why is this? Marc
7
1570
by: Brett | last post by:
I'm not sure why I keep getting this error, "Object reference not set to an instance of an object". Private Function somefunction() as string Dim MyCurrentClass As New Class1 Try For i As Integer = 0 To LinkResults.Length - 1 With MyCurrentClass.SqlCmd_Insert_LinkVB .CommandType = System.Data.CommandType.StoredProcedure
15
5363
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
4
1976
by: rushikesh.joshi | last post by:
Hi All, I have created my own WebControl and want to add it in my aspx page at runtime. it's compiling perfectly, but when i m going to execute, it gives me error of "Object reference not set to an instance of an object." in my server control (ascx.cs file)
1
4219
by: Nathan Sokalski | last post by:
I have a UserControl that I declare programmatically as follows: Dim userctrl as New rightside_portal() The codebehind file for this UserControl looks like the following: Partial Public Class rightside_portal : Inherits System.Web.UI.UserControl Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
2
2338
by: arun1985 | last post by:
In the project i am using i am having the following code and when i upload it to the server.Its givig me the following error in the global.cs file. Server Error in '/' 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...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.