R
Robert A Riedel
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 PtrToStringChars( 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_string" ;
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: (e-mail address removed)
== Email 2: (e-mail address removed)
==
==
== The opinions expressed are my own, and do not necessarily represent
== those of Beckman Coulter, Inc.
==
======================================================================
======================================================================
==
== "Effective education is the key to successful democracy."
==
== "Criticizing 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."
==
======================================================================
======================================================================
"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 PtrToStringChars( 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_string" ;
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: (e-mail address removed)
== Email 2: (e-mail address removed)
==
==
== The opinions expressed are my own, and do not necessarily represent
== those of Beckman Coulter, Inc.
==
======================================================================
======================================================================
==
== "Effective education is the key to successful democracy."
==
== "Criticizing 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."
==
======================================================================
======================================================================