我寫了一個WCF服務,從我的SQL Server數據庫中讀取數據。它工作正常,當調用返回的所有字符串,而是一種方法,如果我調用返回它提供有關超時和太多的數據,這是沒有意義的,以我的一些錯誤崩潰的int的方法...爲什麼我的WCF服務不會返回一個整數?
這裏是我的web服務代碼:
public List<Track> getTrack()
{
List<Track> trackList = new List<Track>();
SqlConnection dbConn = connectToDb();
string _selectQuery = string.Format("SELECT Date, Track, KeyID FROM hdData ORDER BY Track");
try
{
dbConn.Open();
SqlCommand cmd = new SqlCommand(_selectQuery, dbConn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Track Dat = new Track();
Dat.Date = (string)reader[0];
Dat.TrackName = (string)reader[1];
Dat.KeyId = (int)reader[2];
trackList.Add(Dat);
}
dbConn.Close();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
return trackList;
}
如果我拿出KeyId
場正常工作...... KeyId
在數據庫中被定義爲類型int
,是一個自動遞增的字段。
我甚至嘗試它強制轉換爲varchar
但同樣的結果...
我在做什麼錯?
問候, 迪安
確切的錯誤和跟蹤類如下:
好的,確切的錯誤是:
的最大消息大小配額用於傳入消息(65536)具有已超過 。要增加配額,請在適當的綁定元素上使用MaxReceivedMessageSize 屬性。
服務器堆棧跟蹤:
在System.ServiceModel.Channels.HttpInput.ThrowMaxReceivedMessageSizeExceeded()
在System.ServiceModel.Channels.HttpInput.GetMessageBuffer()
在System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(流 的inputStream)
在System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(例外& requestException)
在System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(時間跨度超時)
在System.ServiceModel.Channels.RequestChannel.Request(消息消息,時間跨度 超時)
在System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息 消息,時間跨度超時)
在System.ServiceModel.Channels.ServiceChannel .CALL(字符串動作, 布爾單向,ProxyOperationRuntime操作,對象[]插件, 對象[]奏,時間跨度超時)
在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage 包括methodCall,ProxyOperationRuntime操作)
在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)[0]時異常重新拋出:
在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(即時聊天 reqMsg,即時聊天retMsg)
在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (MessageData & msgData,Int32 type)
at IService1.getTrack()
at Service1Client。getTrack()內部異常:
已超過傳入消息的最大消息大小配額 (65536)。要增加配額,請在適當的綁定元素上使用MaxReceivedMessageSize屬性。
和軌道類:
[DataContract]
public class Track
{
string _Date, _TrackName;
int _KeyId;
[DataMember]
public string Date
{
get { return _Date; }
set { _Date = value; }
}
[DataMember]
public string TrackName
{
get { return _TrackName; }
set { _TrackName = value; }
}
[DataMember]
public int KeyId
{
get { return _KeyId; }
set { _KeyId = value; }
}
}
你能不能給我們確切的錯誤?還有Track類。你也應該關閉你的讀者。 – Fabske 2012-04-06 07:43:30
也許如果你使用MsSql CE數據庫你的KeyId不是一個int,而是一個GUID。然後在嘗試轉換爲int時出現錯誤。 – SynerCoder 2012-04-06 07:51:47
啓用[wcf tracing](http://mkdot.net/mknetug/b/dejan/archive/2008/10/23/wcf-tracing-and-message-logging.aspx)查看詳細的錯誤消息並向我們顯示錯誤。 – Reniuz 2012-04-06 07:57:37