C# WCF测试客户端:未能添加服务。服务元数据可能无法访问。确保您的服务正在运行并公开元数据

C# WCF测试客户端:未能添加服务。服务元数据可能无法访问。确保您的服务正在运行并公开元数据,c#,.net,wcf,exception-handling,microsoft-sync-framework,C#,.net,Wcf,Exception Handling,Microsoft Sync Framework,我当前正在尝试使同步框架示例正常工作: 解决方案编译时不会出现任何错误或警告 但是当我点击F5时,WCF测试客户端启动并抛出以下错误 本地\临时\测试客户端 Projects\10.0\5b6aab8a-6629-4a12-87c2-e9e75ba9c1e4\Client.cs(379,13): 错误CS0246:找不到类型或命名空间名称“schema” (是否缺少using指令或程序集引用?) 下面是上述错误引用的Client.cs中的代码 /// <remarks/> [Syst

我当前正在尝试使同步框架示例正常工作:

解决方案编译时不会出现任何错误或警告

但是当我点击F5时,WCF测试客户端启动并抛出以下错误

本地\临时\测试客户端 Projects\10.0\5b6aab8a-6629-4a12-87c2-e9e75ba9c1e4\Client.cs(379,13): 错误CS0246:找不到类型或命名空间名称“schema” (是否缺少using指令或程序集引用?)

下面是上述错误引用的
Client.cs
中的代码

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.datacontract.org/2004/07/Microsoft.Synchronization")]
public partial class SyncIdFormatGroup
{
    private schema schemaField;
    private System.Xml.XmlElement anyField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Namespace="http://www.w3.org/2001/XMLSchema", Order=0)]
    public schema schema
    {
        get { return this.schemaField; }
        set { this.schemaField = value; }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlAnyElementAttribute(Order=1)]
    public System.Xml.XmlElement Any
    {
        get { return this.anyField; }
        set { this.anyField = value; }
    }
}
//
[System.CodeDom.Compiler.GeneratedCodeAttribute(“svcutil”,“4.0.30319.1”)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(“代码”)]
[System.Xml.Serialization.XmlTypeAttribute(命名空间=”http://schemas.datacontract.org/2004/07/Microsoft.Synchronization")]
公共部分类SyncIdFormatGroup
{
私有模式域;
private System.Xml.xmlement anyField;
/// 
[System.Xml.Serialization.XmlElementAttribute(命名空间=”http://www.w3.org/2001/XMLSchema“,顺序=0)]
公共模式
{
获取{返回this.schemaField;}
设置{this.schemaField=value;}
}
/// 
[System.Xml.Serialization.XmlAnyElementAttribute(顺序=1)]
public System.Xml.XmlElement任意
{
获取{返回this.anyField;}
设置{this.anyField=value;}
}
}
如果有人能帮我解决这个问题,那就太好了。

您是否在服务中启用了mex(元数据交换)端点

<endpoint 
      address="mex" 
      binding="mexHttpBinding" 
      contract="IMetadataExchange"/>


在花了很多时间后,我发现解决方案还可以。出于某种原因,如果我以控制台应用程序的形式运行示例,它就可以正常工作。但在我使用WCFTestClient的那一刻,我就遇到了错误。如果我从合同中删除
[ServiceKnownType(typeof(SyncIdFormatGroup))]
,它将在WCFTestClient中工作。希望这对某人有所帮助。

阅读本页末尾的注释: 注意:如果使用Visual Studio 2010编译这些示例,则首先需要删除对同步框架程序集的引用,然后将程序集引用重新添加到项目中。否则,您将看到“找不到类型或命名空间名称”编译错误。 或

您是否创建了一个名为schema的类?我想它在抱怨schema可能是一个关键字?你能展示schema类的代码吗?它是用[DataContract]属性标记的,它的成员是用[DataMember]属性标记的吗?@stuartmclark我没有任何叫做schema的类。我所指的类是由解决方案上的WCTTestClientCongreats创建的。当你有能力时,请确保将你的答案标记为“已接受”,以便其他人可以从你的成功中学习。干杯~抱歉,伙计们,完全迷路了。已标记答案欢迎使用StackOverflow-第一个答案很好。改进答案的一种方法是澄清你的“页面”;你指的是。。。