Reputation: 25327
I've got following WCF methods:
[OperationContract]
array<Object^>^ GetResult(UInt64 taskId);
[OperationContract]
array<UrlInfo^>^ GetResultAsUriInfo(UInt64 taskId);
when I do return array of strings through GetResult, it works fine. Also, when I return array of UrlInfo through GetResultAsUriInfo it works without any problems. However, when I'm trying to return appay of UrlInfo through GetResult, I'm getting following client side exception:
The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be
used for communication because it is in the Faulted state.
the inner exception is null.
Here's the definition for 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; }
}
Why can't I return an array of UrlInfo as array of objects?
Upvotes: 0
Views: 378
Reputation: 22445
wcf can just pass knowntypes and not generic types - but i m not familiar with c++ syntax.
but you can write your own serializer for your types if you need.
EDIT: i really should read the question more carefully. the problem is your object type in
array<Object^>^ GetResult(UInt64 taskId);
object type can't be serialized in WCF. you should ues the type you expect there.
Upvotes: 2