我有一个在我的控制台应用程序中运行良好的功能。但是当我将它移到我的 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 导入 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 不支持 streamwriter 吗?任何想法将不胜感激!
谢谢,杰森