We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert Group Shapes with Textboxes to EMF Image C# .NET & Avoid Null Reference Exception upon Calling GetShapeRenderer First Time

My sample: sample.zip (7.9 KB)
Aspose version: Aspose.word NET 20.9
My code:

 Document docfile;
                using(var inStream = new FileStream(inputFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    docfile = new Document(inStream);
                var docBuilder = new DocumentBuilder(docfile);
                var shapes = docfile.GetChildNodes(NodeType.Shape, true).ToArray();
                for(int i = 0; i < shapes.Length; i++)
                    using(var iconStream = new MemoryStream())
                        ShapeRenderer renderer = null;
                        var shape = (Shape)shapes[i];
                            renderer = shape.GetShapeRenderer();
                            renderer.Save(iconStream, new ImageSaveOptions(SaveFormat.Emf));
                        catch(Exception e)
                            string msg= e.ToString();
                            renderer = shape.GetShapeRenderer();

Problem is when calling GetShapeRenderer() at the first time it will throw an exception, then catch it and call GetShapeRenderer() again, it will work well.

Can you check and give feedback.
Thank you.


We tested the scenario and have managed to reproduce the following exception on our end upon calling the Shape.GetShapeRenderer method for the first time.

System.NullReferenceException: Object reference not set to an instance of an object.

We have logged this problem in our issue tracking system with ID WORDSNET-21087. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-21087) have been fixed in this Aspose.Words for .NET 20.10 update and this Aspose.Words for Java 20.10 update.