Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CString problems with /clr
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CString problems with /clr

 Post Reply Post Reply
Author
Message
zoobiedoo View Drop Down
Newbie
Newbie


Joined: 17 March 2005
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote zoobiedoo Quote  Post ReplyReply Direct Link To This Post Topic: CString problems with /clr
    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.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 18 March 2005 at 12:27am
So may be you need to compile dll WITH /clr ?
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.187 seconds.