我已在我的服务中创建了一个公共方法,用于从客户端计算机写入错误日志
public partial class ATEServiceLog : ServiceBase
{
public ATEServiceLog()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
TcpChannel tcp = new TcpChannel(9090);
ChannelServices.RegisterChannel(tcp, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(AteBAC), "ATE", WellKnownObjectMode.Singleton);
}
protected override void OnStop()
{
}
public void OnWriteErrorLog(string error)
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter(Application.StartupPath+@"\ATELogCheck.txt", true))
{
file.WriteLine(error);
}
}
}
我创建了最后一个写日志的方法。如何从客户端计算机调用此方法。我试过像
这样的东西NetNamedPipeBinding binding = new NetNamedPipeBinding();
ATEService.ATEServiceLog myService = new ATEService.ATEServiceLog(binding,
new EndpointAddress("tcp://localhost/ATEServiceLog"));
myService.OnWriteErrorLog("Error From My Client");
编译时错误为'ATEService.ATEServiceLog' does not contain a constructor that takes '2' arguments
。我该怎么称呼我的方法。如何在服务器中实现错误日志记录。我的服务将在服务器上运行,并将拥有多个客户端。我必须使用Windows服务在服务器中编写所有客户端错误。