I can’t add System.Windows.Forms to my WCF service library.
I want to return a List<ListViewItem> from my method GetItems(string path), I also tried to add reference of System.Windows.Forms but not found it looks like WCF service library doesn’t support it.
Any ideas how could I do it?
namespace WcfServiceLibrary1
{
[ServiceContract]
public interface IFileManager
{
[OperationContract]
List<ListViewItem> collection(string path);
}
}
This is my Item.cs class:
namespace WcfServiceLibrary1
{
[DataContract]
public class Item
{
[DataMember]
public string name;
[DataMember]
public string path;
[DataMember]
public long size;
[DataMember]
public DateTime date;
}
}
WCF is designed to be an interoperable service platform, therefore I would recommend NOT to use .NET specific datatypes like
ListViewItemas the return types from your service. After all, what will a PHP or Ruby client do with such an object??Instead: use your
Itemclass, return a list of those from your WCF service, and leave it up to the calling application to convert that intoListViewItems as needed….Also: returning
ListViewItemfrom your WCF service would severely limit that service’s functionality. If some client would like to get that data, but present it in some other way (not in aListView), they couldn’t use that service call anymore….. by returning just data elements (like yourItem) class, you leave it up to the caller to decide what to do with that data, and how to possibly show it on screen. I think that’s a good thing and shouldn’t be changed!