Code Snippets
Message_EndpointNotFound
public static void Message_EndpointNotFound(
System.Reflection.MethodBase objMethodBase,
Exception objException,
string sWebServiceAddress,
string sWhatToDoNext)
{
string smessage = string.Empty;
smessage =
"Unable to access the following web service, it has no endpoint." +
Environment.NewLine +
Environment.NewLine +
"'" + sWebServiceAddress + "'" +
Environment.NewLine +
Environment.NewLine +
sWhatToDoNext;
modMessages.Exception(
objMethodBase,
null,
objException,
smessage,
true,
false,
"",
"Web Service Error");
}
Message_MethodNoDataReturned
public static void Message_MethodNoDataReturned(
System.Reflection.MethodBase objMethodBase,
string sMethodName,
string sWebServiceAddress,
string sWhatToDoNext)
{
string smessage = string.Empty;
if (sMethodName.Length == 0)
{
sMethodName = objMethodBase.Name;
}
smessage =
"The web service method '" + sMethodName + "' has returned no data." +
Environment.NewLine +
Environment.NewLine +
"'" + sWebServiceAddress + "'" +
Environment.NewLine +
Environment.NewLine +
sWhatToDoNext;
modMessages.Exception(
objMethodBase,
null,
null,
smessage,
true,
false,
"",
"Web Service Error");
}
Message_UnableToRetrieveAnyData
public static void Message_UnableToRetrieveAnyData(
System.Reflection.MethodBase objMethodBase,
Exception objException,
string sWebServiceAddress)
{
string smessage = string.Empty;
try
{
smessage =
"Unable to retrieve any data from the following web service." +
Environment.NewLine +
Environment.NewLine +
"'" + sWebServiceAddress + "'" +
Environment.NewLine +
Environment.NewLine +
modMessages.sSendScreenShot;
modMessages.Exception(
objMethodBase,
null,
objException,
smessage,
true,
false,
"",
"Web Service Error");
}
catch (Exception ex)
{
modMessages.Exception(
objMethodBase,
null,
ex,
"display the 'WebService_UnableToRetrieveAnyData' message.");
}
}
Message_UnableToReturnAnyDataFromThisXML
public static void Message_UnableToReturnAnyDataFromThisXML(
System.Reflection.MethodBase objMethodBase,
string sWebServiceAddress,
string sXMLRequest,
string sWhatToDoNext)
{
string smessage = string.Empty;
smessage =
"Unable to return any data from the following web service." +
Environment.NewLine +
Environment.NewLine +
"'" + sWebServiceAddress + "'" +
Environment.NewLine +
Environment.NewLine +
"The following query has returned an error:" +
Environment.NewLine +
sXMLRequest +
Environment.NewLine +
Environment.NewLine +
sWhatToDoNext;
modMessages.Exception(
objMethodBase,
null,
null,
smessage,
true,
false,
"",
"Web Service Error");
}
Message_WebConnection_DoesNotExist
public static void Message_WebConnectionDoesNotExist(
bool bFlagError = false)
{
// If clsError.ErrorFlag() = True Then Exit Sub (comment preserved)
System.Windows.Forms.MessageBox.Show(
"You are not connected to the Internet.",
gobjSolution.SolutionFormTitle,
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information);
// sets the flag to an error
clsError.ErrorFlagChange(bFlagError);
}
Message_WebPageGeneralError
public static void Message_WebPageGeneralError(
System.Reflection.MethodBase objMethodBase,
Exception objException,
string sWebPageAddress)
{
string smessage = string.Empty;
smessage =
"Unable to access the following web page:" +
Environment.NewLine +
Environment.NewLine +
"'" + sWebPageAddress + "'";
modMessages.Exception(
System.Reflection.MethodBase.GetCurrentMethod(),
null,
objException,
smessage,
true,
false,
"",
"Web Page Error");
}
Message_WebPageUnauthorized401
public static void Message_WebPageUnauthorized401(
System.Reflection.MethodBase objMethodBase,
Exception objException,
string sWebPageAddress)
{
string smessage = string.Empty;
smessage =
"You do not have permission to access the following web page:" +
Environment.NewLine +
Environment.NewLine +
"'" + sWebPageAddress + "'" +
Environment.NewLine +
Environment.NewLine +
objException.Message;
System.Windows.Forms.MessageBox.Show(
smessage,
My.Settings.APP_WINFORMS_TITLE + " - Unauthorized Access",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information);
smessage = smessage + " (" + System.Reflection.MethodBase.GetCurrentMethod().Name + ")";
Tracer_Add2(
"MESSAGE",
smessage.Replace(Environment.NewLine, " ").Replace(" ", " "));
}
Message_WebPageUnavailable
public static void Message_WebPageUnavailable(
System.Reflection.MethodBase objMethodBase,
Exception objException,
string sWebPageAddress)
{
string smessage = string.Empty;
smessage =
"Unable to access the following web page:" +
Environment.NewLine +
Environment.NewLine +
"'" + sWebPageAddress + "'";
modMessages.Exception(
System.Reflection.MethodBase.GetCurrentMethod(),
null,
objException,
smessage,
true,
false,
"",
"Web Page Error");
}
Services_Exists
public bool Services_Exists()
{
try
{
// VB version has no logic here, so C# preserves that behaviour.
}
catch (Exception ex)
{
modMessages.ErrorMessage(
System.Reflection.MethodBase.GetCurrentMethod(),
ex.Message);
}
// VB returns default(Boolean) = False when no explicit return is given.
return false;
}
Web_IsConnectionAvailable
public static bool Web_IsConnectionAvailable()
{
System.Net.WebRequest objWebReq = null;
System.Net.WebResponse objResp = null;
try
{
var objUrl = new System.Uri("http://www.microsoft.com/");
objWebReq = System.Net.WebRequest.Create(objUrl);
objResp = objWebReq.GetResponse();
return true;
}
catch (System.Runtime.InteropServices.COMException)
{
return false;
}
catch (Exception)
{
return false;
}
finally
{
if (objResp != null)
{
objResp.Close();
objResp = null;
}
objWebReq = null;
}
}
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited Top