我有以下WCF方法:因爲在WCF中傳遞複雜類型會出現什麼問題?
[OperationContract]
array<Object^>^ GetResult(UInt64 taskId);
[OperationContract]
array<UrlInfo^>^ GetResultAsUriInfo(UInt64 taskId);
當我通過調用getResult返回一個字符串數組,它工作正常。另外,當我通過GetResultAsUriInfo返回UrlInfo數組時,它沒有任何問題。然而,當我試圖通過調用getResult返回appay UrlInfo的,我得到下面的客戶端異常:
The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be
used for communication because it is in the Faulted state.
的內部異常是空的。
這裏的定義UrlInfo:
[Serializable]
[DataContract]
public class UrlInfo
{
Uri uri;
[DataMember]
public Uri Uri
{
get { return uri; }
set { uri = value; }
}
string title;
[DataMember]
public string Title
{
get { return title; }
set { title = value; }
}
string description;
[DataMember]
public string Description
{
get { return description; }
set { description = value; }
}
List<string> tags = new List<string>();
[DataMember]
public List<string> Tags
{
get { return tags; }
set { tags = value; }
}
Dictionary<string, string> allMetadata = new Dictionary<string, string>();
[DataMember]
public Dictionary<string, string> AllMetadata
{
get { return allMetadata; }
set { allMetadata = value; }
}
string[] categoryPreferences = new string[0];
[DataMember]
public string[] CategoryPreferences
{
get { return categoryPreferences; }
set { categoryPreferences = value; }
}
爲什麼我不能返回UrlInfo數組作爲對象的數組?
你可以發佈一些代碼,顯示你如何試圖返回urlinfo數組作爲對象數組? – Rajesh 2012-01-30 09:57:22