远程功能抛出错误 [英] Remoting Function Throw An Error
本文介绍了远程功能抛出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一段时间我正在使用远程访问其他程序中的功能点网抛出erorr(非阻塞套接字操作无法立即完成)
我该如何解决这个问题,请帮忙. .
代码
服务器端代码
I am using remoting to access function in another program some time Dot net throwing an erorr (A non-blocking socket operation could not be completed immediately)
how can i solve this problem pls help. .
code
server side code
public string IsServerActive()
{
return "SUCCESS";
}
客户端代码
client side code
private bool IsServerExists(string ServerIP, string ServerPort)
{
try
{
bool connectionStatus = false;
ChannelServices.RegisterChannel(new TcpClientChannel(),false);
Type requiredType = typeof(IServerInterface);
IServerInterface gblRemoteObject = (IServerInterface)Activator.GetObject(requiredType, "tcp://" + ServerIP + ":" + ServerPort + "/ServerRequest");
if (gblRemoteObject.IsServerActive().Trim() == "SUCCESS")
connectionStatus = true;
return connectionStatus;
}
catch
{
return false;
}
}
推荐答案
我通过搜索错误消息找到了答案.
http://www.lesnikowski.com/blog/index.php/a -non-blocking-socket-operation/ [
在.NET3.5中,我们遇到了同样的问题,似乎已经用这种方法解决了.
I found an answer by googling the error message.
http://www.lesnikowski.com/blog/index.php/a-non-blocking-socket-operation/[^]
John T. Angle Says:
June 11th, 2010 at 14:20
Try resetting Blocking property before each of your reader.ReadLine() statements. In C# that is "client.Blocking = true;", I’m not sure what it is in VB.
We had same problem in .NET3.5 which *seems* to have been resolved with this approach.
在做应用程序的数据库配置时,我做过类似的事情.及其工作正常,希望它会为您提供帮助
I have done some thing similar,in making DB configuration of an application and its working fine,hope it''ll help you
private bool Test()
{
bool rvalue = false;
//Connection String for Windows Authentication
string cnstr = @"Data Source=" + dbnametxt.Text + ";Initial Catalog=DBname;Integrated Security=True";
//Connection String for SQL Server Authentication
string sqlcnstr = @"Data Source=" + dbnametxt.Text + ";Initial Catalog=DBname;uid=" + uidtxt.Text + ";pwd=" + pwdtxt.Text + ";";
if (radioButton1.Checked)
{
//create new connection conn with cnsts
}
else if (radioButton2.Checked)
{
//create new connection conn with sqlcnstr,and ask for authentication
}
if (conn.OpenCon())//checking if server is valid or not,OpenCon() will return true if connection is opened
{
rvalue = false;
}
else
{
rvalue = true;
}
return rvalue;
}
这篇关于远程功能抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文