我做了一个Remoting的例子,在本机可以读取数据,但在局域网中其它的电脑就出现了异常,
错误提示:服务器已拒绝客户端凭据..======server代码===============
private void Form1_Load(object sender, EventArgs e)
{
ChannelServices.RegisterChannel(new TcpServerChannel(9999), true);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingTest.Remote), "liao5930", WellKnownObjectMode.Singleton);
}=========Client端代码=========
private void Form1_Load(object sender, EventArgs e)
{
ChannelServices.RegisterChannel(new TcpClientChannel(), true);
RemotingTest.Remote obj = (RemotingTest.Remote)Activator.GetObject(typeof(RemotingTest.Remote), "tcp://192.168.100.101:9999/liao5930");
this.dataGridView1.DataSource = obj.datable();
}
=========RemotingTest代码================
SqlConnection con;
DataSet ds;
SqlDataAdapter da;
string conStr = "Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=ERPSystem;Data Source=LIAO5930;packet size=4096";
string queryStr = "select * from login";
public DataTable datable()
{
using (con = new SqlConnection(conStr))
{
using (da = new SqlDataAdapter(queryStr, con))
{
ds = new DataSet();
da.Fill(ds, "Categories"); return ds.Tables["Categories"];
}
}
}麻烦大家帮忙看看,谢谢了
错误提示:服务器已拒绝客户端凭据..======server代码===============
private void Form1_Load(object sender, EventArgs e)
{
ChannelServices.RegisterChannel(new TcpServerChannel(9999), true);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingTest.Remote), "liao5930", WellKnownObjectMode.Singleton);
}=========Client端代码=========
private void Form1_Load(object sender, EventArgs e)
{
ChannelServices.RegisterChannel(new TcpClientChannel(), true);
RemotingTest.Remote obj = (RemotingTest.Remote)Activator.GetObject(typeof(RemotingTest.Remote), "tcp://192.168.100.101:9999/liao5930");
this.dataGridView1.DataSource = obj.datable();
}
=========RemotingTest代码================
SqlConnection con;
DataSet ds;
SqlDataAdapter da;
string conStr = "Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=ERPSystem;Data Source=LIAO5930;packet size=4096";
string queryStr = "select * from login";
public DataTable datable()
{
using (con = new SqlConnection(conStr))
{
using (da = new SqlDataAdapter(queryStr, con))
{
ds = new DataSet();
da.Fill(ds, "Categories"); return ds.Tables["Categories"];
}
}
}麻烦大家帮忙看看,谢谢了
解决方案 »
- C#窗口程序
- 服务器端控件的OnClientClick事件
- pictureBox1.Image = Image.FromFile("F:\\fc三胞胎.jpg",true)为什么老是提示错误,路径没错呀!问题到底出在哪儿
- textbox下,怎样设置当鼠标离开此框时,当成一次输入完成
- 客户让我导数据给他,用xml,怎么弄
- 不显示删除回复显示所有回复显示星级回复显示得分回复 迎国庆,绘国旗(高分)。
- Button的Image里放图片时,怎么让图片适应Button的大小呢?在线等ing...
- 为什么VS2005运行不起来?
- 关于基类设计的问题.....各位指点指点:
- 无SQL Server(EXESERVER) 服务
- 50求一个正则表达式,很简单的,在线等
- datagridview设置主键列背景颜色
http://hi.baidu.com/liupras/blog/item/90e76d5477007350574e0078.html
http://www.cnblogs.com/scucj/archive/2007/05/09/740808.html
http://www.cnblogs.com/scucj/archive/2007/11/19/740813.html#964078
ensureSecurity
类型:System..::.Boolean如果启用了安全,则为 true;否则为 false。将该值设置为 false 将不会使在 TCP 或 IPC 信道上所做的安全设置无效。有关详细信息,请参见“备注”。
解决“服务器已拒绝客户端凭据”最简单的办法就是把客户端和服务端的RegisterChannel都改为“RegisterChannel(chan,false)”就可以了
ChannelServices.RegisterChannel(new TcpServerChannel(9999), true);
==>
ChannelServices.RegisterChannel(new TcpServerChannel(9999), false); ChannelServices.RegisterChannel(new TcpClientChannel(), true);
==>
ChannelServices.RegisterChannel(new TcpClientChannel(), false);
那如果要用true则怎么办呢?
如果在Internet上,建议改成HTTP通道