2011-01-13 227 views
2

我已經實現了一個Web服務(Classic .Net服務,而不是WCF)來加載數據並返回到用戶控制。這個webservice正在從我創建的用戶控件中調用。但是,當我嘗試使用Web服務讀取文件時,我收到錯誤而不是字節數組。和以前一樣,所有在我的本地機器上都能正常工作,並且在開發&暫存環境中所有地獄都會崩潰。作爲我的測試的一部分,我還改變了Web服務以返回一個簡單的字節數組,這似乎在所有三個實例中都工作得很好,驗證了Web服務按預期工作。以下複製錯誤和Web服務返回此錯誤的代碼。System.Web.Services.Protocols.SoapException:服務器無法處理請求 - 設備未準備就緒

有什麼想法?

注意:webmethod是通過傳遞文件在服務器上的絕對路徑而不是相對路徑來調用的。

錯誤:

網頁錯誤的詳細信息

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MDDR; .NET4.0C) 
Timestamp: Thu, 13 Jan 2011 04:29:30 UTC 

Message: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.IO.IOException: The device is not ready. 

    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 
    at TXTextControl.LoadSettings.?(String A_0, StreamType A_1, ? A_2, ? A_3) 
    at TXTextControl.ServerTextControl.Load(String path, StreamType streamType) 
    at DocumentManager.DocumentService.Document.Load(String documentLocation) in C:\Webs\AR\DocumentManager\DocumentManager\Document.asmx.vb:line 21 
    --- End of inner exception stack trace --- 
Line: 23 
Char: 13 
Code: 0 

CODE:

<WebMethod()> _ 
     Public Function Load(ByVal documentLocation As String) As Byte() 
      Dim serverTextControl As New TXTextControl.ServerTextControl() 
      Dim documentData As Byte() = Nothing 
      Dim docLocation As String = Server.UrlDecode(documentLocation) 
      serverTextControl.Create() 
      'serverTextControl.Text = "This document has been loaded from the server " & System.DateTime.Now 
      serverTextControl.Load(docLocation, textControlUtility.computeStreamType(documentLocation)) 
      serverTextControl.Save(documentData, TXTextControl.BinaryStreamType.InternalUnicodeFormat) 
      serverTextControl.Dispose() 

      Return documentData 
     End Function 
+0

Try/Catch是你的朋友?!? – 2011-01-13 18:54:35

回答

0

它就像你正在發送一個無效的路徑聲音。由於錯誤來自System.IO.IOException。