CString troubles 
Author Message
 CString troubles

Hi. I fear this may be a FAQ, and I apologise if so, but here is my problem:
I have an MFC extension DLL and an MFC app that uses the dll (both compiled
with /CLR, but no __gc classes in either project). Everything works fine in
a debug build, but when I compile a release build (both projects release, or
just the dll release),  I get what seems to me an obscure eror on the
CString passed to the function in the dll.
 Here is a code snippet:

ScCommandWindow *cmdWindow = drawing->getCommandWindow();
cmdWindow->addLine("1234567890");  // this is the function that causes a

//-------- here is the body of the function that dies
void ScCommandWindow::addLine(CString line)
    line = CString("\n\r") + line;


ScCommandWindow is derived solely from CEdit:
" class __declspec(dllexport) ScCommandWindow : public CEdit "

The runtime error is
An unhandled exception of type 'System.NullReferenceException' occurred in
Additional information: Value null was found where an instance of an object
was required.
.. and it appears to occur on the exit of the function addLine.
.. also.. the result of the addLine operation looks something like
"12125656".... with some extra junk,
which leads me to believe that the problem may lie in some kind of mismatch
between wide chars and single byte chars, though I have tried my best to
synchronize this property between the two projects.

Any knowledge would be appreciated.
Thank you--

Wed, 26 May 2004 07:23:58 GMT  
 [ 1 post ] 

 Relevant Pages 

1. CString trouble...

2. CString trouble

3. There real trouble with CString

4. Trouble with CString in a struct.

5. CString array troubles....please help!

6. newbie trouble: CoCreateInstance Error + IWebBrowser trouble...

7. CString& strMyString or CString &strMyString

8. URGENT: BSTR to CString error when calling CString::IsEmpty

9. Using CString functionality without CString variable/cast operator

10. Newbie: CString, string, cstring

11. Why course CString=CString an error ??

12. CString assignment copies to unrelated CString??????


Powered by phpBB® Forum Software