无法在 WCF Silverlight 服务上创建抽象 class 或接口的实例

Cannot create an instance of the abstract class or interface on WCF Silverlight Service

我正在学习两个教程来创建一个超级简单的 WCF Web 服务和 Silverlight 应用程序。

Buiding a Service

Accessing a Service from Silverlight

一切顺利。我创建了我的服务:

using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;

namespace TestOnline.Web.Data
{
    [ServiceContract(Namespace = "")]
    [SilverlightFaultBehavior]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class DataService
    {
        [OperationContract]
        public String TestService()
        {
            return "Service Worked!";
        }
    }
}

我将其添加为服务引用,然后尝试创建一个实例,但在 "proxy = new DataService();"

行收到错误 "Cannot create an instance of the abstract class or interface"

我几乎完全按照教程的步骤操作,我不确定我错过了什么。我当然没有看到很多带有构造函数的服务示例,并且参考代码是自动生成的 - 所以我不想手动添加它们。

有谁知道 solution/what 我做错了什么?谢谢

using System.ServiceModel;
using TestOnline.ServiceReference1;

namespace TestOnline
{
    public partial class MainPage : UserControl
    {
        DataService proxy;

        public MainPage()
        {
            InitializeComponent();
            proxy = new DataService();
        }

        private void TestServiceButton_Click(object sender, RoutedEventArgs e)
        {
            //call service and get response
        }
    }
}

您应该创建生成的代理客户端的实例 class。

如果添加正确,它将被命名为 DataServiceClient()