Information générale
Catégorie:
Microsoft Foundation Classes
Titre:
CString objects in extension DLL
I have created an MFC DLL with some objects that I use in other programs. I created the DLL with the wizard in Visual C++ 5.0, and then declared by objects like the following:
class AFX_EXT_CLASS CClientReg : public CDGMsg
{
// Constructors
public:
CClientReg();
CClientReg (const char *chpClientName, struct sockaddr_in ClientIP,
const char *chpRCList);
virtual ~CClientReg();
// Attributes
public:
CString m_strClientName; // name of the client application
struct sockaddr_in m_ClientIP;// IP address of the client's stream socket
// int m_nRCCount; // number of routing codes in the list
CString m_strRCList; // list of routing codes handled by client
// Operations
public:
virtual bool load(); // put the member data into a buffer for sending
};
I can declare objects of this type in my other apps just fine, and the constructors work OK. However, if I try to set the value of one of the string members using the CString operator '=', or using the Format method, I get a "user breakpoint" message (I don't have any breakpoints set), and the TRACE window shows me this:
HEAP[callctrl.exe]: Invalid Address specified to RtlFreeHeap( d40000, 5f4c0b90 )
and the program crashes.
Shouldn't I be able to do something like:
CClientReg regMsg; // this works OK
regMsg.m_strClientName = _T("Client One"); // this crashes
Also, the program runs fine when compiled in 'Debug' mode. It only breaks when running in release mode.
Any ideas?
Thanks
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement