Print Page | Close Window

CString problems with /clr

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=1980
Printed Date: 15 May 2024 at 9:21pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CString problems with /clr
Posted By: zoobiedoo
Subject: CString problems with /clr
Date Posted: 17 March 2005 at 11:40am

Hello,

I have decided to start using certain .Net Framework classes in my C++ MFC applications, so this requires complilation of the app using the /clr option.  The stdafx.h file #includes the XTreme Toolkit Pro libraries.

The application uses the Codejock commandbars and when the app is run it returns a .Net "System.NullReferenceException" exception when CXTPCommandBars->SetMenu() is called in CMainFrame::OnCreate().  Here is the code in question:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

[...]

CXTPCommandBars* pCommandBars = GetCommandBars() ;

CXTPCommandBar* pMenuBar = pCommandBars->SetMenu ( _T("Menu Bar"), IDR_MAINFRAME ) ;

[...]

}

Stepping into the code using the debugger shows that, inside CXTPCommandBars::GetMenu(), the value of the parameter CString strName seems to be garbage characters rather than the supplied value (ie. _T("Menu Bar") ) .  This garbage CString is then passed to CXTPMenuBar::SetTitle() which errors out further up the call stack in the ATL/MFC class CSimpleStringT class.  I'm guessing the error is caused by the garbage CString passed into GetMenu().

When the app is not compiled with /clr, the code works as expected.  Also note that the XTreme Toolkit Pro dlls are NOT compiled using /clr in either case.

Has anyone run into this problem before?  And/or can someone help with this?  Thanks.




Replies:
Posted By: Oleg
Date Posted: 18 March 2005 at 12:27am
So may be you need to compile dll WITH /clr ?

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net