//WIN FORM客户端代码:
private System.ComponentModel.Container components = null;
private IFaxBusiness faxBus = null;
[STAThread]
static void Main()
{
Application.Run(new ClientForm());
} private void ClientForm_Load(object sender, System.EventArgs e)
{
HttpChannel channel = new HttpChannel(0);
ChannelServices.RegisterChannel(channel); faxBus = (IFaxBusiness)Activator.GetObject(typeof(IFaxBusiness),
"http://localhost:8080/FaxBusiness.soap");
} private void btnSend_Click(object sender, System.EventArgs e)
{
if (txtFax.Text != String.Empty)
{
string fax = "来自" + GetIpAddress() + "客户端的传真:" + System.Environment.NewLine;
fax += txtFax.Text;
faxBus.SendFax(fax);
}
else
{
MessageBox.Show("请输入传真内容!");
}
} private string GetIpAddress()
{
IPHostEntry ipHE = Dns.GetHostByName(Dns.GetHostName());
return ipHE.AddressList[0].ToString();
}//========================================================//WEB FORM 代码:private IFaxBusiness faxBus = null;
private void Page_Load(object sender, System.EventArgs e)
{
HttpChannel channel = new HttpChannel(0);
ChannelServices.RegisterChannel(channel); faxBus = (IFaxBusiness)Activator.GetObject(typeof(IFaxBusiness),
"http://localhost:8080/FaxBusiness.soap");
} private void Button2_Click(object sender, System.EventArgs e)
{
if (txtFax.Text != String.Empty)
{
string fax = "来自" + GetIpAddress() + "客户端的传真:" + System.Environment.NewLine;
fax += txtFax.Text;
faxBus.SendFax(fax);
}
else
{
Response.Write("请输入传真内容!");
}
}
private string GetIpAddress()
{
IPHostEntry ipHE = Dns.GetHostByName(Dns.GetHostName());
return ipHE.AddressList[0].ToString();
}//=========================================================//系统抛的错误//说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代//码中导致错误的出处的详细信息。 //异常详细信息: System.Runtime.Remoting.RemotingException: 信道 http 已注册。//==============================================================//我的疑问:相同的客户端,代码也相同为什么在webform不可以执行呢?
private System.ComponentModel.Container components = null;
private IFaxBusiness faxBus = null;
[STAThread]
static void Main()
{
Application.Run(new ClientForm());
} private void ClientForm_Load(object sender, System.EventArgs e)
{
HttpChannel channel = new HttpChannel(0);
ChannelServices.RegisterChannel(channel); faxBus = (IFaxBusiness)Activator.GetObject(typeof(IFaxBusiness),
"http://localhost:8080/FaxBusiness.soap");
} private void btnSend_Click(object sender, System.EventArgs e)
{
if (txtFax.Text != String.Empty)
{
string fax = "来自" + GetIpAddress() + "客户端的传真:" + System.Environment.NewLine;
fax += txtFax.Text;
faxBus.SendFax(fax);
}
else
{
MessageBox.Show("请输入传真内容!");
}
} private string GetIpAddress()
{
IPHostEntry ipHE = Dns.GetHostByName(Dns.GetHostName());
return ipHE.AddressList[0].ToString();
}//========================================================//WEB FORM 代码:private IFaxBusiness faxBus = null;
private void Page_Load(object sender, System.EventArgs e)
{
HttpChannel channel = new HttpChannel(0);
ChannelServices.RegisterChannel(channel); faxBus = (IFaxBusiness)Activator.GetObject(typeof(IFaxBusiness),
"http://localhost:8080/FaxBusiness.soap");
} private void Button2_Click(object sender, System.EventArgs e)
{
if (txtFax.Text != String.Empty)
{
string fax = "来自" + GetIpAddress() + "客户端的传真:" + System.Environment.NewLine;
fax += txtFax.Text;
faxBus.SendFax(fax);
}
else
{
Response.Write("请输入传真内容!");
}
}
private string GetIpAddress()
{
IPHostEntry ipHE = Dns.GetHostByName(Dns.GetHostName());
return ipHE.AddressList[0].ToString();
}//=========================================================//系统抛的错误//说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代//码中导致错误的出处的详细信息。 //异常详细信息: System.Runtime.Remoting.RemotingException: 信道 http 已注册。//==============================================================//我的疑问:相同的客户端,代码也相同为什么在webform不可以执行呢?
解决方案 »
- 使用EnterPrise Library的问题。
- XSLT 转换xml的内容保存为文本文件,思归大大帮忙呀!
- 数据表封装问题
- 模拟打开某个网页的操作
- 关于分隔字符串问题
- 两个WinForm类的调用函数问题
- 本人的超难解决问题之四
- C# 页面事务中调用存贮过程的问题,详细请进.............
- 谁有JS和C#结合比较好的示例代码,发给偶看一下吧,多谢
- c# flowlayoutpanel拖拽控件的问题
- 关于.Net下的OPC Client编程问题!!!分数不够,开贴再给.
- 有没有在窗体上画线和方框框的控件?现在我需要在窗体上画一些表格.用程序画太麻烦啦,而且改动起来也麻烦.想找一些像VB中能在窗体上画线和
在asp.net中默认使用的是http协议,
我只要首先获得通道:ChannelServices.GetChannel("http://localhost:8080/FaxBusiness.soap");
而不需要注册通道:HttpChannel channel = new HttpChannel(0);
ChannelServices.RegisterChannel(channel);