我正在尝试为没有[ServiceContract]属性的服务创建模拟。
public class MockService : IService
{
public ServiceResult Publish(Message message)
{
//create a factory channel
// NetTcpBinding myBinding = new NetTcpBinding();
try
{
var channelFactory = new ChannelFactory<IService>("ServiceEndpointConfig");
var channel = channelFactory.CreateChannel();
channel.Publish(message);
}
catch (Exception ex)
{
Logger.LogError("Failed to send message", ex);
throw;
}
return ServiceResult.Success;
}
}
但我一直在“尝试获取IService的合同类型,但该类型不是ServiceContract,也不继承ServiceContract。” 对于没有[ServiceContract]属性的服务,使用ChannelFactory的替代方法是什么?
谢谢