Free Support Forum - aspose.com

Eexception thrown when ttrying to convert a second time

Hi,

I'm calling the .NET dll from c++, using a CLI function (also in a dll).

Things work great the first time, then when i call this function the second time, I get a "Parameter Not Valid" exception in System.Drawing

Is there anything i should be calling ro reset things before opening the second doc ? btw - page count works great, when I call save the exception occurs.. code is below:

__declspec

(dllexport) void __cdecl Test3(wchar_t* filepath, ANSWERCB cb)

{

String ^dataDir = gcnew String(filepath);

Document ^doc1 = gcnew Document(dataDir + "1.doc");

int pgcnt = doc1->PageCount;

//Create an ImageSaveOptions object to pass to the Save method

ImageSaveOptions ^options = gcnew ImageSaveOptions(SaveFormat::Jpeg);

options->PageIndex = 2;

options->PageCount = 1;

options->JpegQuality = 100;

options->Resolution = 1000;

char temp[10];

for (int i = 0;i < pgcnt; i++)

{

_itoa(i+1, temp, 10);

String ^s = gcnew String(temp);

String ^sTemp = dataDir + s + "_Doc.Jpeg";

options->PageIndex = i;

doc1->Save(sTemp, options);

cb(i+1); // let caller know we finished a page

}

}

Hi Guy,

Sorry, I was not able to reproduce the issue at my end. Can you please share your sample application to reproduce the issue? Please also share which Operating System and Aspose.Words for .NET version are you using.

Best Regards,

Hi,

It does not seem to occur from a test application.

My application calls this DLL from a different thread each time, and the thread is initialized with:

CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

I tried calling the converter from the main thread, but that crashes immediately, my main thread is sensitive to timing..

Is there any cleanup code I should be calling ?

Hi,

Thanks for your inquiry. We are working over your query and will get back to you soon.

Best regards,

Hi Guy,

It would be difficult to reproduce the issue without the complete code or a sample application. I tried to convert different documents to images in different threads and did not notice any issue.

We are sorry for the inconvenience.

Best Regards,