We ran into a problem since we use the uno automation with LibreOffice on us IIS enviroment.
The follow code is for insert an image into a document, when executing the LAST LINE then the IIS server w3wp.exe causes an exception 0xc0000409.
This code run fine on an desktop enviroment, but causes error on IIS enviroment.
Can anyone help me to understand and solve it ?
Code: Select all
unoidl.com.sun.star.lang.XMultiServiceFactory servfac = (unoidl.com.sun.star.lang.XMultiServiceFactory)xComponent;
Object bitmapTableObject = localContext.getServiceManager().createInstanceWithContext("com.sun.star.graphic.GraphicProvider", localContext);
unoidl.com.sun.star.graphic.XGraphicProvider xGraphicProvider = bitmapTableObject as unoidl.com.sun.star.graphic.XGraphicProvider;
//
unoidl.com.sun.star.beans.PropertyValue[] v = new unoidl.com.sun.star.beans.PropertyValue[1];
v[0] = new unoidl.com.sun.star.beans.PropertyValue();
v[0].Name = "InputStream";
v[0].Value = new uno.Any(typeof(unoidl.com.sun.star.io.XInputStream), OOInputStream.FromFile(tempFile));
unoidl.com.sun.star.graphic.XGraphic graphic = xGraphicProvider.queryGraphic(v);
if (graphic == null) return;
//
unoidl.com.sun.star.text.XTextContent xTextContent = servfac.createInstance("com.sun.star.text.GraphicObject") as unoidl.com.sun.star.text.XTextContent;
unoidl.com.sun.star.beans.XPropertySet xprops = (unoidl.com.sun.star.beans.XPropertySet)xTextContent;
xprops.setPropertyValue("Width", new uno.Any(imgwid));
xprops.setPropertyValue("Height", new uno.Any(imght));
xprops.setPropertyValue("AnchorType", new uno.Any((int)TextContentAnchorType.AS_CHARACTER));
xprops.setPropertyValue("Graphic", new uno.Any(typeof(unoidl.com.sun.star.graphic.XGraphic), graphic));
//
XController xController = ((XModel)xComponent).getCurrentController();
unoidl.com.sun.star.view.XSelectionSupplier xSelectionSupplier = xController as unoidl.com.sun.star.view.XSelectionSupplier;
xSelectionSupplier.select(new uno.Any(typeof(unoidl.com.sun.star.text.XTextRange), txtrange));
unoidl.com.sun.star.text.XText xText = txtrange.getText();
unoidl.com.sun.star.text.XTextCursor xTextCursor = xText.createTextCursor();
xTextCursor.gotoRange(txtrange, false);
[b]xText.insertTextContent(xTextCursor, xTextContent, false); [/b] // on this line rises the exception
best regards
Daniel Junges