我在Web服務層的WCF中存在一個問題。DataContract類中的WCF私有成員引用變爲NULL
當我在WCF中實例化我的類的私有成員(_Wagon)(此實例化不爲空)時,幾秒鐘後,它變爲空。
我一直在嘗試診斷問題,但目前爲止沒有結果。
因此,我正在轉向你們的人來幫助我解決這個問題。
謝謝。
因此,有我的代碼:
[DataContract]
public class RemoteWagon
{
private readonly IWagon _Wagon;
public RemoteWagon(IWagon Wagon)
{
_Wagon = Wagon; //_Wagon isn't null here
}
~RemoteWagon()
{
Trace.WriteLine("Do nothing");
}
[DataMember]
public RemoteBreakpoint Breakpoint
{
set
{
if (value == null)
{
_Wagon.Breakpoint = null; //_Wagon member is NULL...
}
else
{
//... useless code in this context.
}
}
}
}
是所有的實例,並與'RemoteWagon'類發生一個WCF調用的環境中工作,或在多個電話? – mellamokb 2012-04-02 19:24:39
「RemoteWagon」的實例是否在您檢查兩次之間從客戶端到服務器的線路上發送?基本上,WCF將只**串行化一個類的**公共形狀** - 所有用'[DataMember]'屬性標記的東西。其他任何事情都不會**通過電線傳輸,因此在通信鏈路的另一側將不可用。 – 2012-04-02 19:27:15