c# - WCF 测试客户端 : Failed to add a service. 服务元数据可能无法访问。确保您的服务正在运行并公开元数据

标签 c# .net wcf exception-handling microsoft-sync-framework

我目前正在尝试让同步框架示例正常工作:sample

解决方案编译时没有任何错误或警告。

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

Local\Temp\Test Client Projects\10.0\5b6aab8a-6629-4a12-87c2-e9e75ba9c1e4\Client.cs(379,13) : error CS0246: The type or namespace name 'schema' could not be found (are you missing a using directive or an assembly reference?)

下面是来自 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; }
    }
}

如果有人能帮我解决这个问题就太好了。

最佳答案

找到解决方案好吧,我花了很多时间破解了它。出于某种原因,如果我将示例作为控制台应用程序运行,它就可以正常工作。但是当我使用 WCFTestClient 时,我遇到了错误。如果我从契约(Contract)中删除 [ServiceKnownType(typeof(SyncIdFormatGroup))] 它在 WCFTestClient 中工作。希望对某人有所帮助。

关于c# - WCF 测试客户端 : Failed to add a service. 服务元数据可能无法访问。确保您的服务正在运行并公开元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7889115/

相关文章:

wcf - 从 WCF 服务返回 NHibernate 映射类

c# - Silverlight:在页面之间传递复杂对象

c# - 如何将 Unicode 字符转换为其等效的 ASCII 字符

c# - 将 ListView 的高度固定为空白

c# - "Unable to find a version of runtime to run this application"适用于 64 位 Windows 上的 32 位应用程序

c# - 将具有两列的 SQL IN 子句转换为 LINQ

wcf - 通过命名管道绑定(bind)公开 WCF 服务

c# - Azure Service Fabric 中 WCF 服务的 HTTP 终结点

c# - “not all code path return a value”错误在方法中发生,但我确实使用了一些if语句来覆盖所有情况

c# - 在 C# 中获取当前获得焦点的文本框