jssong2000
asked on
Window Service Crashed
Hi Expert,
I work on an existing window service to transfer PDFs to TIFs.
But if one pdf is empty. It will crash the window service. The program could not work on next pdf. And I could not delete it.
The WS could not work on next pdf until I deleted the problem pdf and restarted the WS.
I want to make WS fault tolerant. Please help! Appreciated!!
I work on an existing window service to transfer PDFs to TIFs.
But if one pdf is empty. It will crash the window service. The program could not work on next pdf. And I could not delete it.
The WS could not work on next pdf until I deleted the problem pdf and restarted the WS.
I want to make WS fault tolerant. Please help! Appreciated!!
private void Convert(string strInput)
{
Boolean blnSuccess = true;
string strOutput = "";
if (!File.Exists(strInput))
{
Log(enumLogLevel.Warning, "File not found: " + strInput);
return;
}
try
{
strOutput = GenerateOutputFilename(strInput);
switch (strConvertFromType)
{
case "pdf":
ConvertPDFToImage(strInput, strOutput);
break;
default:
if (strConvertToType == "pdf")
{
CreatePDF(strInput, strOutput);
}
else
{
if (blnConvert1BPP == true)
ConvertImage1BPP(strInput, strOutput);
else
ConvertImage(strInput, strOutput);
}
break;
}
}
catch (Exception ex)
{
blnSuccess = false;
Log(enumLogLevel.Warning, "Error converting image: " + strInput + " - " + ex.Message);
}
if (blnSuccess && blnDeleteSourceFile)
{
try
{
File.Delete(strInput);
}
catch (Exception ex)
{
Log(enumLogLevel.Warning, "Error removing file: " + strInput + " - " + ex.Message);
}
}
return;
}
What the last thing you Log() before it crashes?
ASKER
Log(enumLogLevel.Warning, "File not found: " + strInput);
Thanks!!
Thanks!!
ASKER
Please see below and attachment for the whole process:
using System;
using System.Collections.Generic ;
using System.Linq;
using System.ServiceProcess;
using System.Text;
namespace ImageConverterService
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new ImageConverter()
};
ServiceBase.Run(ServicesTo Run);
}
}
}
ImageConverter.cs
using System;
using System.Collections.Generic
using System.Linq;
using System.ServiceProcess;
using System.Text;
namespace ImageConverterService
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new ImageConverter()
};
ServiceBase.Run(ServicesTo
}
}
}
ImageConverter.cs
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
FileName is correct. It threw an exception when it's an empty file.
Modified to log the problem but continue process.
Modified to log the problem but continue process.