Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2005

Tip: Looking for answers? Try searching our database.

System.NullReferenceException on a CString

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Klynt@noemail.nospam - 28 Feb 2005 15:33 GMT
Project built using /CLR, but code is old and has not been converted
specifically to "managed" (__gc or __value).

Everything seemed to work great, until I got the following error.

I have a class, let's call it CMyLegacyClass, that has some CString (NOT
CString*) member variables.

Problem is, when the destructor is called (which actually has an empty
body), it automatically calls the destructors for my embedded CStrings.  When
this happens, I get a "System.NullReferenceException".

How can this happen since I'm not using __gc, System::String, or CString*
(or any pointers for that matter)?

I even tried adding #pragma unmanaged to the top and #pragma managed to the
bottom of the .CPP and .H files.

Please advise, as this one has me stumped.

Thanks,
Klynt
Gary Chang[MSFT] - 01 Mar 2005 05:25 GMT
Hi Klynt,

I have tested some simple MFC programs with /clr compiler option, however I
could not repro the scenario you figured. Would you please give us a small
self-contain sample to repro this problem?

By the way, since you got the System.NullReferenceException in your class's
destructor function, I think you can take a try on inserting a
System::GC::Collect(); call in that destructor function...

Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ??C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.