У меня есть функция, которая отлично работает в моем консольном приложении. Но когда я перемещаю его в свой WCF, он каждый раз взрывается. Не могу понять, что я делаю не так.
Вот договор на операцию:
<OperationContract()> _
Function SendLetterToBatch(ByVal FinishedLetter As Letter) As Boolean
'Sends a completed letter to the batch for XStream, returns true/false.
Вот СВК:
Импортирует System.Collections Импортирует System.Data Импортирует System.Data.SqlClient Импортирует System.IO
Public Function SendLetterToBatch(ByVal FinishedLetter As Letter) As Boolean Implements ILetterWriter.SendLetterToBatch
Dim CurDateTime As DateTime = DateTime.Now
Dim Format As String = "yyyyMMdd HHmmss"
Dim FileName As String
'Create the text file name. Date / Time (yyyyMMdd HHmmss) to precede claim / policy number
FileName = CurDateTime.ToString(Format) & FinishedLetter.ClaimOrPolicyNo.ToString
'Remove Me -- temporary text file location
FileName = "D:\" & FileName.ToString & ".txt"
'Write the letter to the text file
Using writer As StreamWriter = New StreamWriter(FileName)
writer.Write("01")
writer.Write("02" & FinishedLetter.Body.ToString)
writer.Write("03")
End Using
'Function completed fine, return true
SendLetterToBatch = True
End Function
И, наконец, консольное приложение, вызывающее WCF:
Dim objLetter As New Letter
objLetter._ClaimOrPolicyNo = 99999
objLetter._CompID = 23
objLetter._StateID = 12
objLetter._Body = "Dear Sir, you have not had much luck winning the lottery. We hope we can help. Next time, please choose 6/7/8/9/1 BONUS 2 on your ticket. Thank you, Us."
Console.Write(client.SendLetterToBatch(objLetter))
Я не могу понять это. У кого-нибудь есть идеи? Разве WCF не поддерживает стримрайтер? Благодарим за любую идею!
Спасибо, Джейсон