I am trying to debug a DLL that I have built with MSVS 2008 in VC++. I selected to use the CLR (Common Language Runtime?) so I can take advantage of the System::Net::Socket API. That API seems to be working fine but, one of my functions in the DLL needs to compare the Bytes coming off the socket against a literal string "ON:"
I arranged to send some matching Bytes thru the socket but the comparison always fails. I eventually was able to walk thru the code with the MSVS debugger and I can see the socket Bytes get converted to a String which matches the literal String I am using ("ON:"), yet, for some reason, the equality comparison is always failing (see code below.) The only real clue I have been able to glean from the debugger is that when I attempt to watch the comparison expression (str == "ON:") I get the following error text in the 'value' field of the quickwatch window:
"relational operator failure"
I have no clue what this means, (beyond the obvious that == is NOT working right) and have NOT been able to track the error message down anywhere online or otherwise so far. Below I will list some additional facts about my MSVS solution configuration and the code fragment I am experiencing this with in case any of that allows for some wise MSVS C++ person to see the error of my ways... :)
Thanks in advance:
MSVS Solution contains two projects, one an executable that calls the DLL and one the DLL itself.
The executable project is native code and the DLL project is CLR (managed code?).
Both projects use MultiByte Character Sets (ie..not Unicode)
Here is the code fragment that I am examining in the debugger when this error is encountered:
DWORD Get_Status( ) {
array<Byte>^ RecvBytes = gcnew array<Byte>(256);
array<Byte>^ SendBytes = Encoding::ASCII->GetBytes("CHECK_STATUS");
GO::lsock->Send(SendBytes);
if (GO::lsock->Receive(RecvBytes, GO::lsock->Available, SocketFlags::None)) {
System::String^ str = Encoding::ASCII->GetString(RecvBytes);
return ( str == "ON:") ? 0x1008 : 0; //this always returns 0 at runtime and returns the aforementioned error in the debugger watch window, error: relational operator failure
}
return 0;
}