Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2008 by Ivor Horton; ISBN: 9780470225905
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 23rd, 2009, 02:23 AM
Registered User
Join Date: May 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Jagged Arrays in Managed code

Im working on a Windows Forms project and I cant seem to figure this out. The code compiles without error or warnings however during runtime I get the following error:

An unhandled exception of type 'System.NullReferenceException' occurred
Additional information: Object reference not set to an instance of an object.

I am including a very shortened example of my coding.

In a class header file I have the following:

public ref class Profile
array<String^>^ Keys;

Keys = gcnew array<String^>(10);

In the Main header file I have the following(some stuff such as #include left out for conciseness):
public ref class Main
Profile^ Profiles;
array<Profile^>^ Profiles = gcnew array<Profile^>(10);
Profiles[0]->Keys[0] = "TEST"; //This line generates the error during runtime.

If the object Keys is defined as String^ rather than array<String^>^ I can access that member with Profiles[0]->Keys; However when it is defined as an array I cant access it. This is an array defined in the class that I am making an array of. Ive tried to figure out what Im doing wrong for over 8 hours with no luck.

Last edited by sweinhart2006; May 23rd, 2009 at 02:30 AM..

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using UserControls with Non-Managed Code David_0223 C# 2005 6 January 13th, 2009 03:48 PM
Calling managed code from un-managed code David_0223 C# 7 August 21st, 2007 09:32 AM
Managed & Unmanaged Code? code_lover General .NET 0 January 4th, 2007 10:08 AM
Unmanaged to managed code blemos C# 0 December 21st, 2006 08:34 AM
jagged array help oozener C++ Programming 1 December 4th, 2005 10:45 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.