我正在尝试为 Windows Azure 的 appFabric 提供服务。我是实现和 EchoService,我需要顺便实现和 IEchoContract 接口,所有这些都在服务器端。所以我就这样进行。
在 IEchoContract.cs 上
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace Service
{
[ServiceContract(Name = "EchoContract", Namespace = "http://samples.microsoft.com/ServiceModel/Relay/")]
interface IEchoContract
{
public interface IEchoContract
{
[OperationContract]
string Echo(string text);
}
}}
在 EchoSERvice.cs 上
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace Service
{
class EchoService
{
[ServiceBehavior(Name = "EchoService", Namespace = "http://samples.microsoft.com/ServiceModel/Relay/")]
public class EchoService : IEchoContract
{
public string Echo(string text)
{
Console.WriteLine("Echoing: {0}", text);
return text;
}
}}}
我有两个错误,我不是 C# 专家所以第一个:当我输入 EchoService : IEchoContract 我得到了
'EchoService': member names cannot be the same as their enclosing type
第二,当我把公共接口 IEchoContract
'IEchoContract' : interfaces declare types
所以请帮忙。谢谢。