473,761 Members | 8,463 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 2677
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
2753
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 proxy is installed on an IIS server (Win 2000) with delivers the interface, written in ASP, to the...
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.
2
15326
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 Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet
1
1137
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 content in the debugger - everything's fine until I hit the myListBox->Items->Add(myString,false);...
1
2286
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 the current web request. Please review the stack trace for more information about the error and...
2
2977
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 message: Error Message: Object reference not set to an instance of an object.
0
2653
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 in the code. Exception Details: System.NullReferenceException: Object reference not set to an...
1
2509
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 Atish
0
1983
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
9522
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
9948
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
9902
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
8770
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
7327
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
6603
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();...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2738
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.