ADITYA RAO
asked on
Help required urgently to solve bug in VC++.NET
My application is getting terminated with exception.I kept try catch block and caught exception
Screen hot attached.Already it took for me a day to trace a bug.Now I need to resolve it.
Please help.
Bug.png
Method not found: 'Void System.Net.HttpWebRequest..ctor()'.
Screen hot attached.Already it took for me a day to trace a bug.Now I need to resolve it.
Please help.
Bug.png
ASKER
void CMBOEpmLoginDlg::OnBnClickedLogin()
{
try
{
SetDlgItemText(IDC_LOGIN_STATUS, _T(" "));
Invalidate(TRUE);
CString btnText;
GetDlgItem(ID_LOGIN)->GetWindowText(btnText);
CMBOEpmDefaultSettings^ settings;
if(0 == btnText.CompareNoCase( _T("Login")))
{
CString userName, password, photoshopclose, invalidsettings, wait;
m_Edit_Username.GetWindowTextW(userName);//natarajan commented
m_Edit_Password.GetWindowTextW(password);//natarajan commented
// m_Edit_Username.GetWindowText(userName);//natarajan added
// m_Edit_Password.GetWindowText(password);//natarajan added
if(MBOEpmManager::CMBOEpmPhotoshopInterfacer::PsRunning())
{
photoshopclose.LoadString(IDS_PHOTOSHOP_CLOSE);
SetDlgItemText(IDC_LOGIN_STATUS, photoshopclose.operator LPCWSTR());//natarajan commented
// SetDlgItemText(IDC_LOGIN_STATUS, photoshopclose.operator LPCSTR());//natarajan added
Invalidate(TRUE);
EnableOrDisableControls(TRUE);
return;
}
else if(String::IsNullOrEmpty(settings->UserAuthenticationURL) || String::IsNullOrEmpty(settings->ClientId) || String::IsNullOrEmpty(settings->ClientSecret) )
{
invalidsettings.LoadString(IDS_INVALIDSETTINGS);
SetDlgItemText(IDC_LOGIN_STATUS, invalidsettings.operator LPCWSTR());//natarajan commented
// SetDlgItemText(IDC_LOGIN_STATUS, invalidsettings.operator LPCSTR());//nataraja added
Invalidate(TRUE);
EnableOrDisableControls(TRUE);
return;
}
wait.LoadString(IDS_WAIT);
SetDlgItemText(IDC_LOGIN_STATUS, wait.operator LPCWSTR());//natarajan commented
// SetDlgItemText(IDC_LOGIN_STATUS, wait.operator LPCSTR());//natarajan added
Invalidate(TRUE);
// disable login button
EnableOrDisableControls(FALSE);
String^ gcUsername = gcnew String (userName);
String^ gcPassword = gcnew String (password);
CMBOEpmLoginReq^ epmLoginRequest = gcnew CMBOEpmLoginReq(gcUsername, gcPassword);
theApp.IsLoginProcess = true;
CMBOEpmRequestProcessor^ RequestProcessor = gcnew CMBOEpmRequestProcessor((IEmpMessage*)this, epmLoginRequest);
MBOEpmManager::CMBOEpmLog::LogAllErrorList(L"Constructor successfull Debug Log >>> ",92,"");
try
{
bool temp = RequestProcessor->StartProcessing(false);
}
catch(Exception^ ex)
{
AfxMessageBox((CString)ex->ToString());
MBOEpmManager::CMBOEpmLog::LogAllErrorList(L"Catch block Debug Log >>> ",92,ex->Message);
}
return;
}
//
if(0 == btnText.CompareNoCase( _T("Log Out")))
{
}
}
catch(...)
{ }
finally
{
theApp.IsLoginProcess = false;
}
}
ASKER
bool MBOEpmManager::CMBOEpmRequestProcessor::StartProcessing(bool IsRetryJSON)//@AdityaR if function return false data will go offline else online
{
MBOEpmManager::CMBOEpmLog::LogAllErrorList(L"Start Processing started Debug Log >>> ",32,""); //@AdityaR 2.0.8 27/03/2017
if(theApp.IsLoginProcess == false)
{
MBOEpmManager::CMBOEpmLog::LogAllErrorList(L"Inside loop to check internet connection Debug Log >>> ",32,""); //@AdityaR 2.0.8 27/03/2017
if(CMBOEpmTrackerApp::IsInternetAvailable()==false) //@AdityaR 2.0.7.1 28/3/2017 BEGIN
{
MBOEpmManager::CMBOEpmLog::LogAllErrorList(L"Internet connection is not available.Please check internet connection Debug Log >>> ",32,""); //@AdityaR 2.0.8 27/03/2017
}
}//@AdityaR 2.0.7.1 28/3/2017 END
else
{
MBOEpmManager::CMBOEpmLog::LogAllErrorList(L"Internet connectivity checking bypassed Debug Log >>> ",32,""); //@AdityaR 2.0.8 27/03/2017
}
String^ strMessageType=String::Empty;
try
{
String^ responseString =String::Empty;
HttpWebResponse^ response ;
Stream^ streamResponse ;
StreamReader^ streamRead;
System::Net::HttpWebRequest^ request ;
bool blnJSON_InternetFailure = true;
int ijudge = 0;
MBOEpmManager::CMBOEpmLog::LogAllErrorList(L"About to get responce type Debug Log >>> ",32,""); //@AdityaR 2.0.8 27/03/2017
strMessageType = m_ReqBaseObject->GetResponseType();
do
{
CTime c1 = GetCurrentTime();
MBOEpmManager::CMBOEpmLog::LogAllErrorList(L"Request object Ready to send Salesforce Debug Log >>> ",35,strMessageType); //@AdityaR 2.0.8 27/03/2017
try
{
request = gcnew System::Net::HttpWebRequest();
response = gcnew HttpWebResponse();
responseString = String::Empty;
request = m_ReqBaseObject->GetRequestStream();
response = dynamic_cast<HttpWebResponse^>(request->GetResponse());
MBOEpmManager::CMBOEpmLog::LogAllErrorList(L"Responce begin from Salesforce Debug Log >>> ",37,"Started getting responce"); //@AdityaR 2.0.8 27/03/2017
streamResponse = response->GetResponseStream();
streamRead = gcnew StreamReader(streamResponse);
responseString = streamRead->ReadToEnd();
MBOEpmManager::CMBOEpmLog::LogAllErrorList(L"Responce completed from Salesforce Debug Log >>> ",37,"Call back function called"); //@AdityaR 2.0.8 27/03/2017
responseString = responseString->ToString();
streamResponse->Close();
streamRead->Close();
response->Close();
}
catch(Exception^ ex)
{
try
{
streamResponse->Close();
streamRead->Close();
response->Close();
}
catch(Exception^ ex)
{
}
}
CTime c2 = GetCurrentTime();
CTimeSpan cp = c2-c1;
if(cp.GetTotalSeconds() > 20000)
{
MBOEpmManager::CMBOEpmLog::LogAllErrorList(L"Total request responce time is more than 20 seconds****************************** Debug Log >>> ",47,strMessageType); //@AdityaR 2.0.8 27/03/2017
}
else
{
MBOEpmManager::CMBOEpmLog::LogAllErrorList(L"Total request responce time is less than 20 seconds------------------------------ Debug Log >>> ",51,strMessageType); //@AdityaR 2.0.8 27/03/2017
}
if(IsRetryJSON == true)
{
ijudge = JudgeProperJSON_Responce(responseString);
if(ijudge == 1 || ijudge == 2)
{
blnJSON_InternetFailure = false;
}
else
{
blnJSON_InternetFailure = true;//@AdityaRfunction return false only in case responce is undefined and user has denied retry
}
}
}while(IsRetryJSON == true && blnJSON_InternetFailure == false && ijudge != 2);
if(blnJSON_InternetFailure == true)//@AdityaR In undefined case stop the call to callback function itself
{
m_pEmpMessage->SendCallBackMessage(strMessageType,responseString);
}
return blnJSON_InternetFailure;
}
catch(Exception^ ex)
{
/*
Note:
DO NOT REMOVE THIS TRY CATCH.
............................
In normal scenario it's working perfectly without the following exception handling.
If the operator close the form before the worker thread get executed completely,
We can't call the method 'SendCallBackMessage()' because the object already disposed.
*/
try
{
///String^ Excep = System::String::Format("The website says : {0}",ex->Message); ADITYA TODO
///m_pEmpMessage->SendCallBackMessage(strMessageType,ex->Message); ADITYA TODO
}
catch(...)
{ }
return true;
}
}
ASKER
The project here is using mfc and cli both,image attached
Project-Inclusions.png
Project-Inclusions.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I was trying,I got solution
i wonder that the error message contains types 'Void' or 'Boolean' which should be "void" and "bool" in vc++.
Sara