I\'m in a delicate situation: As the title suggests, I can\'t seem to connect to a WCF service I wrapped up in a Windows Service. I followed the tutorial http://msdn.microso
For anyone who is encountering similar issues without detailed error, I'll describe what my problem was about. In my Visual Studio project, I used a class similar to the following:
public class Info
{
public string Key { get; set; }
public string Value { get; set; }
public Info(string key, string value)
{
this.Key = key;
this.Value = value;
}
}
The difference to the other project (which worked) is that this POCO has a constructor that takes parameters, thus doesn't provide a standard constructor without any arguments. But this is needed in order for Info objects to be serialized (I hope I use that term correctly here) and deserialized. So in order to make it work, either just add a standard constructor which may just do nothing, or (perhaps better) use the following instead:
[DataContract]
public class Info
{
[DataMember]
public string Key { get; set; }
[DataMember]
public string Value { get; set; }
public Info(string key, string value)
{
this.Key = key;
this.Value = value;
}
}
I didn't think about the DataContract part before, because I didn't use any custom constructor and just initialized the objects like
Info info = new Info { Key = "a", Value = "b" };