this line of code:
Aspose.Words.Drawing.Shape image = builder.InsertImage(fileName);
is causing me some grief, but it’s complicated.
it will work on my system, and many other systems. it has been deployed to 15 client sites, as well as several internal systems, and it works fine on them.
it is called within a custom dll that has been developed over the past several years.
however…
it will NOT work on a virtual (azure) 2016 Datacenter machine.
It crashes so hard that exceptions are not caught - I have that code in a try catch block, the catch block is supposed to write the error message to a log file, and it’s not happening, I just get a kernalbase exception in the system event log.
it ALSO works when running in a standalone program, on that same machine.
Aspose version 19.9
.Net version 4.5.2
Full code (currently)
public void insertImage(string fileName, bool forceResize)
{
NoWordLogging nwl = new NoWordLogging();
NoWordLogging.writeLog(“Create builder”);
Aspose.Words.DocumentBuilder builder = new DocumentBuilder(m_Document.AsposeDocument);
NoWordLogging.writeLog("Builder created, create image from " + fileName);
try
{
Aspose.Words.Drawing.Shape image = builder.InsertImage(fileName);
NoWordLogging.writeLog("Image Created, resize image");
}
catch (Exception E)
{
NoWordLogging.writeLog(" exception :" + E.Message);
}
// if (forceResize)
// resizeImage(image);
// m_Cell.FirstParagraph.AppendChild(image);
}
log file:
Create builder
Builder created, create image from C:\CompanyFiles_provantagesoftware\tmpImages\858_8547E9451282637E_11.tif
(and that’s it, that’s the entire log file)
edit: more:
I changed the code to the following:
public void insertImage(string fileName, bool forceResize)
{
NoWordLogging nwl = new NoWordLogging();
NoWordLogging.writeLog(“Create builder”);
Aspose.Words.DocumentBuilder builder = new DocumentBuilder(m_Document.AsposeDocument);
System.Drawing.Image dImage = null;
NoWordLogging.writeLog(“Builder created, create image from " + fileName);
try
{
dImage = System.Drawing.Image.FromFile(fileName);
NoWordLogging.writeLog(“Image Created, assign image”);
}
catch (Exception E)
{
NoWordLogging.writeLog(” exception :" + E.Message);
}
try
{
Aspose.Words.Drawing.Shape image = builder.InsertImage(dImage);
NoWordLogging.writeLog("Image Created, resize image");
}
catch (Exception E)
{
NoWordLogging.writeLog(" exception :" + E.Message);
}
// if (forceResize)
// resizeImage(image);
// m_Cell.FirstParagraph.AppendChild(image);
}
the builder.addImage is still blowing up.
my log results:
Create builder
Builder created, create image from C:\CompanyFiles_provantagesoftware\tmpImages\858_86804E1300B8A565_11.tif
Image Created, assign image
edit(again)
updated to Aspose.words version 19.12, and it is still broken