我目前正在尝试让同步框架示例正常工作: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/