Free Support Forum - aspose.com

ExecuteWithRegions Value cannot be null. Parameter name: startParent

Trying to use the new GetChildDataSource functionality in the IMailMergeDataSource interface.
But once the GetChildDataSource is executed I get the following error:
Value cannot be null.
Parameter name: startParent

I have included the Document and MailMerge datasource C# file
The datasource is collection of the following object:

//Parent
public class Indem
{
public string Coverage;
public int Period;
public IEnumerable Objects; //The child collection
}

//Child
public class IndemObj
{
public string Name;
public int Period;
}

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. The problem might occur because your template is not very well designed. There are two regions in the same paragraph, which is not allowed. I modified your template (see the attachment). Please let me know how it goes on your side.

Hope this helps.

Best regards.

No still get the same error using your template.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Could you please create simple application, which will allow me to reproduce the problem on my side? I will check the issue and provide you more information.

Also, Here you can find simple code and template, which demonstrates the technique:

Best regards.

Hi, I have been able to work around the issue. Apparently it goes into the GetValue function for the TableStart:Object field and than throws the error. So I added a check to only return Structs and Strings.
This is my code that works:

public IMailMergeDataSource GetChildDataSource(string tableName)

{

object datasource;

if (TryGetPropertyValue(tableName, out datasource) && datasource is IEnumerable)

return new MailMergeObjectDatasource((IEnumerable)datasource, tableName);

throw new InvalidOperationException("No property with the name " + tableName + " that implements IEnumerable was found in the current datasource");

}

public bool GetValue(string fieldName, out object fieldValue)
{
return TryGetPropertyValue(fieldName, out fieldValue) && (fieldValue is ValueType || fieldValue is string) //This is the fix
}

protected virtual bool TryGetPropertyValue(string propName, out object value)

{

var obj = _enumerator.Current;

var property = obj.GetType().GetProperty(propName);

if (property != null)

{

value = property.GetValue(obj, null);

return true;

}

value = null;

return false;

}

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

It is perfect that you already found the reason of the problem. Please feel free to ask in case of any issues, I will be glad to help you.

Best regards.

I would just like to point out that it’s still a bugg, it shouldn’t go into function “GetValue” for child tables.

Hi Fredrik,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I logged your request in our defect database. You will be notified as soon as the issue is resolved.

Best regards.

The issues you have found earlier (filed as 12206) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(50)