Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi Frends,
I need help, I have a code in VC++.net 2008, at runtime one function is getting skipped automatically. any one know the reason please reply.

Thanx

MIDL
WriteTESTLog("TEST_LOGS_NIGHT",_T("Before FireMTURL::") + _T(minsat.MT_URL));
           
 resp = FireMTURL(DB_DATA.msisdn,msg_send,minsat.MT_URL,MT_SHORTCODE);
            
WriteTESTLog("TEST_LOGS_NIGHT",_T("After FireMTURL::") + _T(minsat.MT_URL) +_T(" # ") + _T(resp

));

1. before FireMTURL method log is written.
2. in above code whenever control reached at FireMTURL() method its getting closed and application is restarted.
Posted
Updated 22-Feb-11 21:57pm
v3
Comments
OriginalGriff 23-Feb-11 2:58am    
You are going to have to give move info than that!
Perhaps a relevant code fragment would help?
[no name] 23-Feb-11 3:03am    
Show the code.
aravindkrgec 23-Feb-11 3:20am    
Let me know the nature of the function skipped. Shall you please explain the qn more clearly????
CPallini 23-Feb-11 3:36am    
Code, Watson, we need code. And a detailed description of the scenario.
Olivier Levrey 23-Feb-11 4:05am    
So the method is not skipped but makes your application crash: it's a big difference. What's inside FireMTURL?

OK I will do your job and ask a proper question (you should do it by yourself if you want a chance to have answers...).

Correct me if I am wrong. Your FireMTURL function looks like:

CString FireMTURL(CString msisdn, CString mesg, CString MT_URL, CString MT_SHORTCODE)
{
     //...
}


You are telling that your application crashes and restarts as soon as it tries to enter that function. Since you put lots of logs inside it, you should see the logs written, but there are none. So your function is not called.

If all this is correct, then I suppose there is a problem in the arguments:

1 - First of all, don't pass CString to your function, pass CString& instead. This will avoid calling copy-constructor.
2 - Before calling the function, check that all your CString parameters are valid. If one of them is corrupted, then the function call would probably crash due to the call of the copy-constructor.
3 - If one of the CString is corrupted, it is most likely that you accessed its internal data using the GetBuffer or GetBufferSetLength methods without calling ReleaseBuffer or ReleaseBufferSetLength after modification.

To use references, change your function declaration to:
CString FireMTURL(CString& msisdn, CString& mesg, CString& MT_URL, CString& MT_SHORTCODE)
{
    //...
}

To call that function, you can use your previous code without changing anything more:
resp = FireMTURL(DB_DATA.msisdn, msg_send, minsat.MT_URL, MT_SHORTCODE);
 
Share this answer
 
v2
Comments
ShilpiP 23-Feb-11 5:41am    
You deserve +5 :)
Olivier Levrey 23-Feb-11 5:42am    
Thanks :)
sam_ckp 23-Feb-11 7:25am    
HI Olivier, i passed the parameters like this..

resp = FireMTURL((LPCSTR)DB_DATA.msisdn, (LPCSTR)msg_send,(LPCSTR) minsat.MT_URL, (LPCSTR)MT_SHORTCODE);

is it right ??
Olivier Levrey 23-Feb-11 7:46am    
This is correct. But if you do like this, it means you are passing a char* (or wchar*) to your function. So you need to modify the code inside your function.

My suggestion was to use a reference instead of a pointer so you don't need to change anything inside your function. See my new answer.
Hi,
Just as Olivier said, check the validity of the strings. Also check the value of resp, the return value. By the way did you debug the code to see where the actual problem is.....
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900