我在wcf服务中有三个DataContract
个类。我已经为客户端添加了服务引用,我的两个类工作得很好,但第三个类没有出现在服务引用中。我不在我的服务界面中使用这个类,这可能是我的问题的原因吗?这是这堂课:
[DataContract]
public class Security
{
public Security(){ }
public string Sha1(string input)
{
byte[] hash;
using (SHA1CryptoServiceProvider Sha1Provider = new SHA1CryptoServiceProvider())
{
hash = Sha1Provider.ComputeHash(Encoding.Unicode.GetBytes(input));
}
var sb = new StringBuilder();
foreach (byte b in hash) sb.AppendFormat("{0:x2}", b);
return sb.ToString();
}
}
如果重要,我已将System.Security.Cryptography
的引用添加到我的客户端。
答案 0 :(得分:0)
If the DataContract is not exposed in your ServiceContract, the client won't get the DataContract because it isn't needed.
A more robust explanation can be found on this question: DataContract not available at WCF client service reference