我目前正在努力让同步框架示例正常运行:sample
解决方案可以编译出任何错误或警告。
但是当我点击F5时,WCF测试客户端会启动并抛出以下错误。
Local \ Temp \ Test Client 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; }
}
}
如果有人可以帮我解决这个问题,那将会很棒。
答案 0 :(得分:3)
找到解决方案好了,花了很多时间我破解了它。出于某种原因,如果我将示例作为控制台应用程序运行它只是工作正常。但是当我使用WCFTestClient时,我收到了错误。如果我从合同中删除[ServiceKnownType(typeof(SyncIdFormatGroup))]
,它可以在WCFTestClient中使用。希望有所帮助。
答案 1 :(得分:2)
您是否在服务中启用了mex(元数据交换)端点?
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
答案 2 :(得分:0)
阅读页面末尾的注释: 注意:如果使用Visual Studio 2010编译这些示例,则首先需要删除对Sync Framework程序集的引用,然后将程序集引用重新添加到项目中。否则,您将看到“无法找到类型或命名空间名称”编译错误。 http://code.msdn.microsoft.com/Database-Sync-SQL-Server-7e88adab#content 要么 http://code.msdn.microsoft.com/Database-SyncSQL-Server-e97d1208