Free Support Forum - aspose.com

Receiving "Operation could destabilize the runtime" from Aspose.Words.Document DLL

I am running Microsoft .NET framework Version: 2.0.50727.3620 ASP.Net Version2.0.50727.3618. Using ASPOSE.Words Assembly runtime version v1.1.4322 Version 8.0.0.0.

We have moved the application that was executing from one service provider to another (Network Solutions). After moving we are executing on the functions which generates a report and received an exception "Operation could destabilize the runtime" The stack trace shows:

Aspose.words.document.[](Stream [], loadformat [], string[]) +1285

Aspose.words.document.[](Stream [], loadformat [], string[]) +109

Aspose.words.document..ctor(string fileName, LoadFormat loadFormat, String password) +126

Aspose.words.document..ctor(string, filename) +9

EventM.ReportGen.Generate() +146

........

Code looks like:

public string Generate()
{
string reportDir = HttpContext.Current.Server.MapPath("Reports/");
string filePath = Path.Combine(reportDir, template);
if (!File.Exists(filePath))
return string.Format("Report {0} template does not exist on server", template);
if (reporttype == "I")
PopulateIncident();
else
PopulateEvent();
PopulateMisc();
Document doc = new Document(filePath);
// Header Merge Fields
String[] fieldNames = new String[]
{"CurrentDate","CurrTime","DoctorName","CalendarName","StartDate","EndDate","StartDay","EndDay","CenterName"};
Object[] fieldValues = new Object[]
{CurrentDate,CurrTime,DoctorName,CalendarName,StartDate,EndDate,StartDay,EndDay,CenterName};
doc.MailMerge.Execute(fieldNames, fieldValues);
doc.MailMerge.ExecuteWithRegions(dt);

.....

The highlighted "Document doc = new Document(filePath); statement appears to be where we are throwing the error.

Are there issues with the DLL I am using? I tried finding a later version, but it was incompatible with ASP.Net version 2.

Hello

Thanks for your request. How can I reproduce the issue on my side using Aspose.Words? Could you please attach your input document which will allow me to reproduce the problem on my side?

Best regards,

Attached is the Word File used as the template.

Hello

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words (10.1.0) and the following code for testing:

Document doc = new Document("C:\\Temp\\BookingForm.docx");

String[] fieldNames = new String[] { "CurrentDate", "CurrTime", "DoctorName", "CalendarName", "StartDate", "EndDate", "StartDay", "EndDay", "CenterName" };

Object[] fieldValues = new Object[] { DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now };

doc.MailMerge.Execute(fieldNames, fieldValues);

doc.Save("C:\\Temp\\out.docx");

You can download the latest version from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Best regards,