Hi Adam,
Thanks for responding. My code is below. I have studied the documentation and forums, and the error appears to be coming from calling the setlicense method multiple times; perhaps two calls are occurring simultaneously. One suggestion was to call SetLicence in the application startup, but I haven't figured out how to do that on the server side in Silverlight. My current solution is to call SetLicence each time the service is used, immediately destroying the Words.License object afterwards. This generally works, but not always.
Thanks for any suggestions.
Randy
<OperationContract()>
Public Sub CreateMergeDoc(ByVal sTemplateFileName As String, ByVal sOutputFileName As String, ByVal sCustFolder As String, ByVal asTag() As String, ByVal asData() As String)
Dim nCounter As Integer = 0
Dim sProc As String = "AsposeMergeService.CreateMergeDoc"
Dim oInputDoc As Document
Try
Dim oWordsLic As New Aspose.Words.License()
oWordsLic.SetLicense("Aspose.Words.lic")
oWordsLic = Nothing
Dim sInputFolder As String = HttpContext.Current.Server.MapPath(scFOLDER_DOCTEMPLATE)
Dim sOutputFolder As String = HttpContext.Current.Server.MapPath(scFOLDER_DOCOUTPUT & "\" & sCustFolder)
Dim sInputPath As String = sInputFolder & "\" & sTemplateFileName & ".docx"
Dim sOutputPath As String = sOutputFolder & "\" & sOutputFileName & ".docx"
If Not System.IO.Directory.Exists(sOutputFolder) Then
System.IO.Directory.CreateDirectory(sOutputFolder)
End If
'--- replace tags with data
oInputDoc = New Document(sInputPath)
With oInputDoc
Dim oRange As Range = oInputDoc.Range
Dim nTest As Integer
For nCounter = 0 To UBound(asTag)
nTest = oRange.Replace(asTag(nCounter), asData(nCounter), False, False)
Next
'--- do it again, to handle conditional/merge data in the conditional text
For nCounter = 0 To UBound(asTag)
nTest = oRange.Replace(asTag(nCounter), asData(nCounter), False, False)
Next
End With
oInputDoc.Save(sOutputPath, SaveFormat.Docx)
Catch ex As Exception
Debug.WriteLine(sProc & " Error at Counter= " & nCounter.ToString & ", FieldName= " & asTag(nCounter) & " Data= " & asData(nCounter))
Debug.WriteLine(sProc & " Message= " & ex.Message)
Finally
oInputDoc = Nothing
End Try
End Sub