Aspose.OCR.1.7.0.Resources.zip is being used by another process exception

Hi,

I’m useing Aspose OCR 1.7.0 in .a web service implemented with .NET and I’m getting this error related to Aspose resources:

System.IO.IOException: The process cannot access the file ‘C:\Webservices_LIVE\DocumentCatalogue\Aspose.OCR.1.7.0.Resources.zip’ because it is being used by another process. 

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)”

Do I have to release the object ? I see OCR.OcrEngine has not a Dispose method.

What can it be the reason for that?

Thanks a lot,

Marcelo

Hi Marcelo,


First of all, please accept our apologies for the delayed response.

As per your presented scenario, it seems that the resources are not getting released properly in your application. In order to further investigate the problem cause, and to suggest a solution, we will need to review your application on our end. Therefore we would request you to please provide us the standalone run-able sample application to replicate the said exception.

Moreover, the OcrEngine class does not implement System.IDisposable therefore you will not be able to initialize its object in a “using” construct. Although, it is suggested to load the Aspose.OCR resource file in a “using” construct to make sure the FileStream object is disposed properly when not needed. Please check the below provided code snippet for your reference.

C#

// Resource file: every version of the API uses specific resource file
const string resourceFileName = “Aspose.OCR.1.8.0.Resources.zip”;
// Source file: the file on which OCR will be performed
string imageFile = “sampleocr.bmp”;
Console.WriteLine("Performing OCR on " + imageFile + “…”);
// Initialize OcrEngine
OcrEngine ocr = new OcrEngine();
// Set the image
ocr.Image = ImageStream.FromFile(imageFile);
// Add language
ocr.Languages.AddLanguage(Language.Load(“english”));
// Load the resource file
using (ocr.Resource = new FileStream(resourceFileName, FileMode.Open))
{
try
{
// Process the whole image
if (ocr.Process())
{
// Get the complete recognized text found from the image
Console.WriteLine(“Text recognized.\n” + ocr.Text);
}
}
catch (Exception ex)
{
Console.WriteLine("Exception: " + ex.Message);
}
}

Hope this helps a bit.