473,554 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Troubleshooting "Object reference not set to an instance of an object." Managed Exception. How?

I am completely baffled when the following managed exception is thrown:
"Object reference not set to an instance of an object" from a nested
subroutine when referencing a variable allocated on the program stack.

Given the following simple example:

void T( System::String * S )
{
const wchar_t __pin * pchars PtrToStringChar s( S ) ;

size_t n = S->Length ; // Exception appears to be thrown here,
why???

// More stuff ....

}

void V( void )
{
System::String * str = S"this_is_a_str ing" ;

T( str ) ;
}

The exception appears to be thrown at the line 'size_t n = S->Length ;' in
T(), which frankly seems rather bizarre. Worse, the exception occurs on
fairly infrequent occassions in an (multi-threaded) application, and it is
not readily reproducable.

I need some suggestions on how to go about troubleshooting this problem.

Are there still open issues with garbage collection in a VC.NET 2003 app
using the 1.1.4322 framework?

If not, how can a variable be destroyed before all references to it are
deleted?

--
=============== =============== =============== =============== ==========
=============== =============== =============== =============== ==========
==
== Bob Riedel
== Beckman Coulter, Incorporated
== PO Box 8000 W-529
== 200 S Kraemer Blvd
== Brea CA 92822-8000
==
== Email 1: ra******@beckma n.com
== Email 2: ra******@mindsp ring.com
==
==
== The opinions expressed are my own, and do not necessarily represent
== those of Beckman Coulter, Inc.
==
=============== =============== =============== =============== ==========
=============== =============== =============== =============== ==========
==
== "Effective education is the key to successful democracy."
==
== "Criticizin g the actions of others offers so little risk, and
== requires so little effort that it is, without exception, the tool
== of the lazy and of the foolish -- who have neither the intelligence
== to discover, nor the discipline to pursue, a realistic
== alternative."
==
=============== =============== =============== =============== ==========
=============== =============== =============== =============== ==========
Nov 16 '05 #1
1 2660
I am withdrawing this question. It appears that my simplification of the
problem was a little too simple, and I left out the step that was the cause
of the problem. The exception, from what I can tell, is being thrown
correctly.

"Robert A Riedel" <ra**********@b eckman.com> wrote in message
news:u6******** *****@TK2MSFTNG P11.phx.gbl...
I am completely baffled when the following managed exception is thrown:
"Object reference not set to an instance of an object" from a nested
subroutine when referencing a variable allocated on the program stack.

Given the following simple example:

void T( System::String * S )
{
const wchar_t __pin * pchars PtrToStringChar s( S ) ;

size_t n = S->Length ; // Exception appears to be thrown here,
why???

// More stuff ....

}

void V( void )
{
System::String * str = S"this_is_a_str ing" ;

T( str ) ;
}

The exception appears to be thrown at the line 'size_t n = S->Length ;' in
T(), which frankly seems rather bizarre. Worse, the exception occurs on
fairly infrequent occassions in an (multi-threaded) application, and it is
not readily reproducable.

I need some suggestions on how to go about troubleshooting this problem.

Are there still open issues with garbage collection in a VC.NET 2003 app
using the 1.1.4322 framework?

If not, how can a variable be destroyed before all references to it are
deleted?

--
=============== =============== =============== =============== ==========
=============== =============== =============== =============== ==========
==
== Bob Riedel
== Beckman Coulter, Incorporated
== PO Box 8000 W-529
== 200 S Kraemer Blvd
== Brea CA 92822-8000
==
== Email 1: ra******@beckma n.com
== Email 2: ra******@mindsp ring.com
==
==
== The opinions expressed are my own, and do not necessarily represent
== those of Beckman Coulter, Inc.
==
=============== =============== =============== =============== ==========
=============== =============== =============== =============== ==========
==
== "Effective education is the key to successful democracy."
==
== "Criticizin g the actions of others offers so little risk, and
== requires so little effort that it is, without exception, the tool
== of the lazy and of the foolish -- who have neither the intelligence
== to discover, nor the discipline to pursue, a realistic
== alternative."
==
=============== =============== =============== =============== ==========
=============== =============== =============== =============== ==========

Nov 16 '05 #2

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

Similar topics

0
2736
by: Bob Cannistraci | last post by:
A three-tier user authentication system was running without a problem for almost a year and now is suddenly dysfunctional. We don't know of any changes to any of the servers. It's quite maddening. The details: 1) We know the COM+ app is instanced on the COM+ server (Win 2000). The component graphic spins when CreateObject is called. 2) The...
1
2813
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: ...
2
15318
by: xhenxhe | last post by:
I don't some Excel automation. I've created a program that opens and Excel template and inputs information to it. It runs great on my machine. When I build and deploy I have a user that keep getting the error message: "Object reference not set to an instance of an object." Here is the code that generates the message: Dim xlApp As...
1
1124
by: jk | last post by:
Hi, I'm trying to add an object to a checked listbox using VC++2005 Express. I tries adding a managed String (String ^) and objects that implement their own version of the ToString() method. I always get the same error message: "object reference not set to an instance of an object". The objects are initialized and I can see them and their...
1
2267
by: Gummy | last post by:
Hello, I've been banging my head against the wall for a few days on this. When I run a page, either in "View in Browser" or I actually build the solution, I occasionally and very randomly get the following message: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of...
2
2967
by: louie.hutzel | last post by:
This JUST started happening, I don't remember changing any code: When I click the submit button on my form, stuff is supposed to happen (which it does correctly) and a result message is posted back to the same page at the top of my form alerting the user that their request has been approved or denied. However, the end result is an error...
0
2642
by: Tamer Ibrahim | last post by:
Hi, Sometimes, I got the following error message when I use ajax calendar control on some aspx pages : 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...
1
2489
by: atishrg | last post by:
Hello all, I am facing a problem,, that I am not able to trace a "OBJECT REFERENCE NOT SET TO AN INSTANCE OF AN OBJECT" EXCEPTION .... as I am using On error goto _Lable as soon as this exception occures control directly shifted to error lable I want to excute next line even if this exception occures... Can Any one help to do this ...
0
1972
by: raghudr | last post by:
Hi all, I am coding for displaying a splash screen until a big job is finished.I am getting an exception:only during the first start of the system.Rest all the time it is working fine. Only when i restart the PC my application will be launced by windows services at startup and i get the exception saying:
0
7612
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...
0
7536
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...
1
7576
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...
0
6163
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...
1
5443
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...
0
5165
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...
0
3564
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2027
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
853
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...

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.