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

Free Support Forum - aspose.com

Populate Template Image with NULL or Empty URL during Building LINQ Reports in C# .NET - Handle System.ArgumentException


i am binding my report template image with a url coming from a datasource, sometimes the url is empty. in this case I have an error :

Message=The argument cannot be null or empty string.
Nom du paramètre : fileName
Arborescence des appels de procédure :
à .(String , String )
à .(String )
à . ( , , String )
à . ( , , IDictionary , )
à .( , IDictionary , )
à . ( )
à .( , )
à .(String[] , Object[] , , , , )
à .(String[] , Object[] , , )
à Aspose.Words.Reporting.ReportingEngine.BuildReport(Document document, Object[] dataSources, String[] dataSourceNames)
à Aspose.Words.Reporting.ReportingEngine.BuildReport(Document document, Object dataSource, String dataSourceName)
à Aspose.Words.Reporting.ReportingEngine.BuildReport(Document document, Object dataSource)
à TestGrapheAspose.Program.Main(String[] args) dans C:\dev\perso\TestGrapheAspose\TestGrapheAspose\Program.cs :ligne 24

to reproduce the issue you can use this simple template
testEmpty.zip (19.6 KB)


Please also create a standalone simple console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size. Thanks for your cooperation.

here is an example TestGrapheAspose.zip (58.1 KB) (I used this sample for testing graphs in aspose that is why the name of the project is not related to the current issue)


We managed to reproduce the same problem on our end. For the sake of any correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-19848. We will further look into the details of this problem and will keep you updated on the status of the linked issue. We apologize for your inconvenience.

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

Well, throwing a proper exception is one solution, i would prefer aspose not to crash with an empty image.


I am afraid, the following code does not throw any exception when running with Aspose.Words for .NET 20.2 on our end:

Document doc = new Document("E:\\TEmp\\TestGrapheAspose\\testImageEmpty.dotx");

// Create a Reporting Engine.
ReportingEngine engine = new ReportingEngine();
engine.Options = ReportBuildOptions.RemoveEmptyParagraphs;
var datasource = new DS();
// following works
//datasource.Image = System.IO.Directory.GetCurrentDirectory() + "\\Download.jpg";

// following does not work
datasource.Image = string.Empty;

engine.BuildReport(doc, datasource, "DS");

//ShapeVisitor shapeVisitor = new ShapeVisitor();

//var shapes = doc.GetChildNodes(NodeType.Shape, true);
//foreach (var shape in shapes.OfType<Shape>())
//  if(shape.HasChart)
//  {
//    foreach (var serie in shape.Chart.Series)
//    {
//      int datpointCount = serie.DataPoints.Count; // why is it always zero
//      shape.Chart.AxisX.Scaling.Minimum = new Aspose.Words.Drawing.Charts.AxisBound(2);
//    }
//  }


Please see attached generated DOCX file: