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

Free Support Forum - aspose.com

Aspose Throw Exception When Execute "MailMerge.Execute"


When we try to execute the mail merge, we got an exception.

The exception is "Unable to cast object of type 'x2a6f63b6650e76c4.x40e041b61bf0cab3' to type 'x2a6f63b6650e76c4.xddb28bb303a8678b'"

The code are:

class Program
static void Main(string[] args)
License license = new License();
Document doc = new Document("test.doc");
string[] names = new string[1]{"abc"};
object[] values = new object[1]{"$0.00"};
doc.MailMerge.Execute(names, values);

The test doc is attached



Hi Frank,

Thanks for your request. I cannot reproduce the problem on my side. I use the latest version of Aspose.Words for testing. You can download the latest version from here:


Best regards,

Hi I have exactly the same problem (Aspose 9.3.0) The exception is "Unable to cast object of type
‘x2a6f63b6650e76c4.x40e041b61bf0cab3’ to type

Public Sub SetFields(ByVal row As DataRow)
End Sub

I fixed the problem by doing that:

Public Sub SetField(ByVal name As String, ByVal value As String)
WordFile.MailMerge.Execute(New String() {name}, New Object() {value})
End Sub

Public Sub SetFields(ByVal row As DataRow)

Dim i As Integer = 0
For Each item In row.ItemArray

Dim name As String = item.ToString()
Dim value As String = row.Table.Columns(i).ToString()

SetField(name, value)

i = i + 1
Catch ex As Exception
Throw New Exception(“Aspose error”)
End Try

End Sub

Cheers, Alex

Hi Alex,

Thank you for sharing your experience. But as I mentioned, the problem does not occur with the latest version. So you can simply upgrade to resolve this problem.

Best regards,