Hi,
I am working on maintenance of an ASP .Net application built in F/W 1.1. I am having the following error while calling fucntion in business class that uses dlls "Interop.HTML2RTF.dll" & "Html2Rtf.dll" following is the function call and called function:
ERROR: Found a low surrogate char without a preceding high surrogate at index: 367. The input may not be in this encoding, or may not contain valid Unicode (UTF-16) characters. Parameter name: chars
Can somebody help me in this regard?
Rao Kamran
Here is the Code:
-----------------------------------------------------------------------
CALL:
------
Dim a, b, c As String
a = System.Convert.ToString(RTrim(FPCN_Number))
b = System.Convert.ToString(namesArray(i))
c = System.Convert.ToString(lsFileDirectory)
retval = bsvSingleRTF.Generate_Blanket_RTF_Sngle(a, b, c)
FUNCTION BEING CALLED:
----------------------
Public Function Generate_Blanket_RTF_Sngle(ByVal asFPCNNumber As String, ByVal asParentEndName As String, ByVal lsFileDirectory As String) As Integer
Dim aParam(0) As SqlParameter
Dim ldr As SqlDataReader
Dim retVal As Integer = 0
'supplied as parameters
Dim FPCNnumber As String = asFPCNNumber
Dim ParentEndName As String = asParentEndName
lsFileDirectory = lsFileDirectory
Dim FPCNRegistration As New bsvFPCNRegistration
Dim registrationDataset As bsvFPCNRegistrationData
Dim FPCNAPCNRegistration As New bsvFPCNUseAPCNRegistration
FPCNAPCNRegistration.of_GetTopMarkingList(asFPCNNumber)
registrationDataset = FPCNRegistration.of_GetByFPCNNumber(FPCNnumber)
registrationDataset.Merge(FPCNRegistration.of_GetCustomerLetterByFPCNNumber(FPCNnumber))
'Do all Declarations here
Dim asSubject As String = ""
Dim asFPCNDate As DateTime
Dim asImplementationDate As DateTime
Dim asSamDate As DateTime
Dim asSamDateDisplay As String = ""
Dim asProducts As String = ""
Dim asFPCN_Number As String = ""
Dim asDescription As String = ""
Dim asReason As String = ""
Dim asReasonForChange = ""
Dim asImpact As String = ""
Dim asBUQAEng As String = ""
Dim asBUQAEngEmail As String = ""
Dim asOriginator As String = ""
Dim asEmailAddress As String = ""
Dim asDescriptionOfChange As String = ""
Dim asCustomerResponse1 As String = ""
Dim asCustomerResponse2 As String = ""
Dim topReader As SqlDataReader
'Get ToSideMarking
topReader = FPCNAPCNRegistration.of_FPCN_Get_IP_TM_TCL(asFPCNNumber, asParentEndName)
'asFPCNDate = registrationDataset.Registration(0).created
If registrationDataset.Customer_Letter.Count > 0 Then
With registrationDataset.Customer_Letter(0)
Dim dataRow() As dataRow = registrationDataset.Personnel.Select(String.Format("Personnel_ID = '{0}'", registrationDataset.Registration(0).prod_eng_Personnel_ID))
If dataRow.Length > 0 Then
asBUQAEng = String.Format("{0} {1} ", dataRow(0)("first_name"), dataRow(0)("last_name"))
asBUQAEngEmail = dataRow(0)("email_address")
End If
asFPCNDate = .letter_dispatch_date
Dim h As New HTML2RTF.Converter
h.OutputTextFormat = HTML2RTF.eOutputTextFormat.Rtf
asSubject = .subject
asImplementationDate = .implementation_date
'asProducts = Replace(FPCNAPCNRegistration.of_FPCN_Get_Distinct_TM_For_Parent_End_CSV(asFPCNNumber, asParentEndName), ",", ", ")
While topReader.Read()
If IsDBNull(topReader("Marketing_Part")) Then
asProducts = ""
Else
asProducts = asProducts + topReader("Marketing_Part") + ","
End If
End While
asProducts = removeDupsArray(asProducts)
asProducts = Replace(asProducts, ",", ", ")
asFPCN_Number = FPCNnumber
If Not IsDBNull(.body) OrElse .body.Trim() <> "" Then asDescription = replaceLicense(h.Convert(Replace(.body, vbCrLf, "<br>")))
Try
If .sample_availability_date <> "" And Not IsDBNull(.sample_availability_date) Then
If IsDate(.sample_availability_date) Then
asSamDate = .sample_availability_date
asSamDateDisplay = asSamDate.ToString("MMMMMMMMMM dd, yyyy")
Else
asSamDateDisplay = .sample_availability_date
End If
Else
asSamDateDisplay = ""
End If
Catch e As Exception
End Try
Dim errataNumber As String = ""
If Not .Iserrata_numberNull Then errataNumber = .errata_number
If .rev_change And .fab_change Then
asReason = String.Format("Update to Errata {0} and Additional Manufacturing Capacity", errataNumber)
ElseIf .rev_change Then
asReason = String.Format("Update to Errata {0}", errataNumber)
ElseIf .fab_change Then
asReason = "Additional Manufacturing Capacity"
End If
If Not IsDBNull(asReason) OrElse asReason.Trim() <> "" Then asReason = replaceLicense(h.Convert(Replace(asReason, vbCrLf, "<br>")))
If Not IsDBNull(.impact) OrElse .impact.Trim() <> "" Then asImpact = replaceLicense(h.Convert(Replace(.impact, vbCrLf, "<br>")))
If IsDBNull(.reason_for_change) Then
asReasonForChange = ""
Else
asReasonForChange = .reason_for_change
End If
If Not IsDBNull(.Originator) OrElse .Originator.Trim() <> "" Then asOriginator = replaceLicense(h.Convert(Replace(.Originator, vbCrLf, "<br> ")))
If Not IsDBNull(.EmailAddress) OrElse .EmailAddress.Trim() <> "" Then asEmailAddress = replaceLicense(.EmailAddress)
If Not IsDBNull(.DescriptionOfChange) OrElse .DescriptionOfChange.Trim() <> "" Then asDescriptionOfChange = replaceLicense(.DescriptionOfChange)
If Not IsDBNull(.CustomerResponse1) OrElse .CustomerResponse1.Trim() <> "" Then asCustomerResponse1 = replaceLicense(.CustomerResponse1)
If Not IsDBNull(.CustomerResponse2) OrElse .CustomerResponse2.Trim() <> "" Then asCustomerResponse2 = replaceLicense(.CustomerResponse2)
End With
Dim ls_Template As String
Dim asFileName As String
Dim ls_Templatecustomer As String
Dim fileName As String
Dim customerfilename As String
'mzia (Replcing special characters ( / \ : * ? " < > | ) in Customer name)
ParentEndName = Replace(ParentEndName, "/", "-")
ParentEndName = Replace(ParentEndName, "\\", "-")
ParentEndName = Replace(ParentEndName, ":", "-")
ParentEndName = Replace(ParentEndName, "*", "-")
ParentEndName = Replace(ParentEndName, "?", "-")
ParentEndName = Replace(ParentEndName, Chr(34), "-")
ParentEndName = Replace(ParentEndName, "<", "-")
ParentEndName = Replace(ParentEndName, ">", "-")
ParentEndName = Replace(ParentEndName, "|", "-")
ParentEndName = Replace(ParentEndName, "~", "-")
ParentEndName = Replace(ParentEndName, "!", "-")
ParentEndName = Replace(ParentEndName, "#", "-")
ParentEndName = Replace(ParentEndName, "$", "-")
ParentEndName = Replace(ParentEndName, "%", "-")
ParentEndName = Replace(ParentEndName, "^", "-")
ParentEndName = Replace(ParentEndName, "&", "-")
ParentEndName = Replace(ParentEndName, ";", "-")
ParentEndName = Replace(ParentEndName, "'", "-")
'-------------------------------------------------------------------------
' Dim ls_RTFFileName As String = Trim(lsFileDirectory) & FPCNnumber & ".RTF"
Dim ls_RTFFileName As String = Trim(lsFileDirectory) & FPCNnumber & "_" & ParentEndName & ".RTF"
'Get the File name
fileName = lsFileDirectory & "FAB_Template2.rtf"
Dim fs As New FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)
'########## COLLECT SOURCE DOCUMENT IN TO STREAMREADER
Dim sr As New StreamReader(fs)
'read the contents into the string
While (sr.Peek() <> -1)
ls_Template = sr.ReadToEnd()
End While
sr.Close()
'########## COLLECT SOURCE DOCUMENT IN TO STREAMREADER ##############
'''**ADDED BY EK ON 11022004
asParentEndName = Replace(asParentEndName, "~", " ")
asParentEndName = Replace(asParentEndName, "$", "\\")
asParentEndName = Replace(asParentEndName, "^", "/")
'########## START WRITING RTF BODY TEXT TO RTF DOCUMENT
ls_Template = Replace(ls_Template, "(FPCN#)", asFPCN_Number)
ls_Template = Replace(ls_Template, "(Date Requested)", asFPCNDate.ToString("MMMMMMMMMM dd, yyyy"))
ls_Template = Replace(ls_Template, "(Customer Name)", asParentEndName)
ls_Template = Replace(ls_Template, "(Change Implementation Date)", asImplementationDate.ToString("MMMMMMMMMM dd, yyyy"))
ls_Template = Replace(ls_Template, "(Sample Availability Date)", asSamDateDisplay)
ls_Template = Replace(ls_Template, "(Title)", asSubject)
ls_Template = Replace(ls_Template, "(Products)", asProducts)
ls_Template = Replace(ls_Template, "(Origin)", asOriginator)
ls_Template = Replace(ls_Template, "(Address)", asEmailAddress)
ls_Template = Replace(ls_Template, "(Description)", asDescription)
ls_Template = Replace(ls_Template, "(Change)", asDescriptionOfChange)
ls_Template = Replace(ls_Template, "(Reason)", asReason + asReasonForChange)
ls_Template = Replace(ls_Template, "(Impact)", asImpact)
ls_Template = Replace(ls_Template, "(CR1)", asCustomerResponse1)
ls_Template = Replace(ls_Template, "(CR2)", asCustomerResponse2)
'ls_Template = Replace(ls_Template, "(BU QA Admin)", asBUQAEng)
'ls_Template = Replace(ls_Template, "buqaadmin@buqaadmin.com", asBUQAEngEmail)
'ls_Template = Replace(ls_Template, "mailto:buqaadmin@buqaadmin.com", "mailto:" + asBUQAEngEmail)
'########## START WRITING RTF BODY TEXT TO RTF DOCUMENT ###############
'###### CHECK THE VALUE OF INCLUDE QUAL DATA FLAG
Dim bsvRegistration_instance As New bsvFPCNUseAPCNRegistration
Dim ldr_Include_Qual_Data As SqlDataReader
Dim Include_Flag_Value As Integer
'########### COMMENTED BY JL on 041223
Dim strRet As String
'############# COMPLETE RTF DOCUMENT GENERATION
Dim myStream As FileStream = New FileStream(ls_RTFFileName, FileMode.Create)
Dim myWriter As System.IO.StreamWriter = New System.IO.StreamWriter(myStream)
myWriter.Write(ls_Template)
myWriter.Close()
myStream.Close()
retVal = 1
Else
retVal = 0
End If
Return retVal
End Function
|