WCF c#.net中的EndPointNotFoundException [英] EndPointNotFoundException in WCF c#.net

查看:93
本文介绍了WCF c#.net中的EndPointNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我在WCF c#.net中有EndPointNotFoundException.消息的粗​​体部分出现异常.服务器和客户端之间通过预定义中动态生成的代理之间的连接.但是当服务器调用客户端功能时,就会发生此异常.

命名空间QuBIC.VirtualCyber​​neticEnviornment
{
公共局部类Cyber​​neticEnviornmentWnd:QuBIC.Core.QuBICServiceBaseForm
{
私有ServiceHost _Cyber​​neticEnviornmentServiceHost;
私人布尔IamconnectedtoTaskManager = false;
公共ServiceAgent MyAgent
{
得到{
return(ServiceAgent)_MyAgent;
}
}
公共Cyber​​neticEnviornmentWnd()
{
InitializeComponent();
//_ServiceAgent.Signin + =新的SigninDelegate(_ServiceAgent_Signin);

}
公共Cyber​​neticEnviornmentWnd(ServiceAgentBase argMyAgent):base(argMyAgent)
{
InitializeComponent();
//_ServiceAgent.Signin + =新的SigninDelegate(_ServiceAgent_Signin);
grdConnections.DataSource = MyAgent.ConnectionPool.Connections;
标题="Cyber​​neticEnvironment [" + argMyAgent.MyProfile.ToString()+]";
txtTaskMonitoringConsoleHostMachine.Text = Environment.MachineName;
MyAgent.OnSignin + =新的OnSigninDelegate(MyAgent_OnSignin);
MyAgent.UpdatedExternalMessage + =新的EventHandler< MessageEventArgs>(MyAgent_UpdatedExternalMessage);
StartHosting();
}
void MyAgent_UpdatedExternalMessage(对象发送者,MessageEventArgs e)
{
SetExternalMessage(e.Message);
}
void MyAgent_OnSignin(ServiceProfile rmtargServiceProfile)
{
lblConnectionCount.Text = MyAgent.ConnectionPool.Count.ToString();
}

private void StartHosting()
{
_Cyber​​neticEnviornmentServiceHost =新的ServiceHost(typeof(Service));
_Cyber​​neticEnviornmentServiceHost.AddServiceEndpoint(typeof(IService),new NetTcpBinding(SecurityMode.None),"net.tcp://" + MyAgent.MyProfile.MyMachineProfile.ToString()+"/" + MyAgent.MyProfile.ServiceType.ToString()+ 服务");
_Cyber​​neticEnviornmentServiceHost.Open();
}
私有void btnConnectToTaskMonitoringConsole_Click(对象发送者,EventArgs e)
{
lblConnectionStatus.Text =请稍候...";

ConnectToTaskMonitoringConsole();
IamconnectedtoTaskManager = true;
lblConnectionStatus.Text =已连接";
btnConnectToTaskMonitoringConsole.Enabled = false;
}

私有void ConnectToTaskMonitoringConsole()
{

SetInternalMessage(正在连接到任务监视控制台");
IService _TaskMonitoringProxy;
_TaskMonitoringProxy = ConnectionManager.ConnectToTaskManagerConsole(txtTaskMonitoringConsoleHostMachine.Text,txtTaskMonitoringConsolePort.Text,MyAgent);
lblConnectionStatus.Text =已连接";
btnConnectToTaskMonitoringConsole.Enabled = false;

}

/*内部无效UpdateConnectionRequest(MachineProfile argMachineProfile,EAgentType rmtargAgent)
{
如果(rmtargAgent == EAgentType.Avatar)
{

Program._Cyber​​nticEnvironment.IsAvatarLoggedOn = true;
}
否则,如果(rmtargAgent == EAgentType.QuBICAgent)
{
_QuBICAgentProxy = ChannelFactory< IPlayer> .CreateChannel(新NetTcpBinding(SecurityMode.None),新EndpointAddress("net.tcp://" + argMachineProfile.MachineName +:" + argMachineProfile.Port +"/QuBICAgentService"));


Program._Cyber​​nticEnvironment.IsQuBICAgentLoggedOn = true;
}

_ConnectionPool.InsertConnection(argMachineProfile,rmtargAgent);

lblConnectionCount.Text = _ConnectionPool.Count.ToString();
} */
内部void SetInternalActivity(string argActivity)
{

txtInternalActivity.AppendText(argActivity + Environment.NewLine);
}
私有无效btnPingQuBIC_Click(对象发送者,EventArgs e)
{
_MyAgent.ConnectionPool [EServiceType.QuBICAgent] .Ping(EServiceType.Cyber​​neticEnvironment);
}
私有void btnStartNewGame_Click(对象发送者,EventArgs e)
{
NewGame();
}
公共无效NewGame()
{
如果(IamconnectedtoTaskManager == true)
{
DialogResult res = MessageBox.Show(您要开始一个新游戏吗?","Query",MessageBoxButtons.YesNo);
开关(res)
{
case DialogResult.是:

MyAgent.ConnectionPool [EServiceType.QuBICAgent] .RequestToPlayGame();

//MyAgent.ConnectionPool [EServiceType.Avatar] .Ping(EServiceType.Cyber​​neticEnvironment);

MyAgent.ConnectionPool [EServiceType.Avatar] .RequestToPlayGame();
MyAgent.ConnectionPool [EServiceType.Referee] .RequestToPlayGame();


MessageBox.Show(我已向所有玩家和裁判请求游戏");
休息;
大小写DialogResult.No:
MessageBox.Show(无法开始新游戏");
休息;
}
}
其他
{
MessageBox.Show(网络环境首先应连接到任务管理器");
}

}
私有无效的Cyber​​neticEnviornmentWnd_Load(对象发送者,EventArgs e)
{
}
private void groupBox1_Enter(对象发送者,EventArgs e)
{
}


}
}

hello

i have EndPointNotFoundException in WCF c#.net. exception occurs in the bold area of message. where the connection between the server and clients through dynamically generated proxies in pre define. but when the server call the client fucntion then this exception occurs.

namespace QuBIC.VirtualCyberneticEnviornment
{
public partial class CyberneticEnviornmentWnd: QuBIC.Core.QuBICServiceBaseForm
{
private ServiceHost _CyberneticEnviornmentServiceHost;
private bool IamconnectedtoTaskManager = false;
public ServiceAgent MyAgent
{
get {
return (ServiceAgent)_MyAgent;
}
}
public CyberneticEnviornmentWnd()
{
InitializeComponent();
//_ServiceAgent.Signin += new SigninDelegate(_ServiceAgent_Signin);

}
public CyberneticEnviornmentWnd(ServiceAgentBase argMyAgent): base(argMyAgent)
{
InitializeComponent();
//_ServiceAgent.Signin += new SigninDelegate(_ServiceAgent_Signin);
grdConnections.DataSource = MyAgent.ConnectionPool.Connections;
Title = "CyberneticEnvironment [" + argMyAgent.MyProfile.ToString() + "]";
txtTaskMonitoringConsoleHostMachine.Text = Environment.MachineName;
MyAgent.OnSignin += new OnSigninDelegate(MyAgent_OnSignin);
MyAgent.UpdatedExternalMessage += new EventHandler<MessageEventArgs>(MyAgent_UpdatedExternalMessage);
StartHosting();
}
void MyAgent_UpdatedExternalMessage(object sender, MessageEventArgs e)
{
SetExternalMessage(e.Message);
}
void MyAgent_OnSignin(ServiceProfile rmtargServiceProfile)
{
lblConnectionCount.Text = MyAgent.ConnectionPool.Count.ToString();
}

private void StartHosting()
{
_CyberneticEnviornmentServiceHost = new ServiceHost(typeof(Service));
_CyberneticEnviornmentServiceHost.AddServiceEndpoint(typeof(IService), new NetTcpBinding(SecurityMode.None), "net.tcp://" + MyAgent.MyProfile.MyMachineProfile.ToString() + "/" + MyAgent.MyProfile.ServiceType.ToString() + "Service");
_CyberneticEnviornmentServiceHost.Open();
}
private void btnConnectToTaskMonitoringConsole_Click(object sender, EventArgs e)
{
lblConnectionStatus.Text = "Please Wait...";

ConnectToTaskMonitoringConsole();
IamconnectedtoTaskManager = true;
lblConnectionStatus.Text = "Connected";
btnConnectToTaskMonitoringConsole.Enabled = false;
}

private void ConnectToTaskMonitoringConsole()
{

SetInternalMessage("Connecting to Task Monitoring Console");
IService _TaskMonitoringProxy;
_TaskMonitoringProxy = ConnectionManager.ConnectToTaskManagerConsole(txtTaskMonitoringConsoleHostMachine.Text, txtTaskMonitoringConsolePort.Text, MyAgent);
lblConnectionStatus.Text = "Connected";
btnConnectToTaskMonitoringConsole.Enabled = false;

}

/*internal void UpdateConnectionRequest(MachineProfile argMachineProfile, EAgentType rmtargAgent)
{
if (rmtargAgent == EAgentType.Avatar)
{

Program._CybernticEnvironment.IsAvatarLoggedOn = true;
}
else if (rmtargAgent == EAgentType.QuBICAgent)
{
_QuBICAgentProxy = ChannelFactory<IPlayer>.CreateChannel(new NetTcpBinding(SecurityMode.None), new EndpointAddress("net.tcp://" + argMachineProfile.MachineName + ":" + argMachineProfile.Port + "/QuBICAgentService"));


Program._CybernticEnvironment.IsQuBICAgentLoggedOn = true;
}

_ConnectionPool.InsertConnection(argMachineProfile, rmtargAgent);

lblConnectionCount.Text = _ConnectionPool.Count.ToString();
}*/
internal void SetInternalActivity(string argActivity)
{

txtInternalActivity.AppendText(argActivity + Environment.NewLine);
}
private void btnPingQuBIC_Click(object sender, EventArgs e)
{
_MyAgent.ConnectionPool[EServiceType.QuBICAgent].Ping(EServiceType.CyberneticEnvironment);
}
private void btnStartNewGame_Click(object sender, EventArgs e)
{
NewGame();
}
public void NewGame()
{
if (IamconnectedtoTaskManager == true)
{
DialogResult res = MessageBox.Show("Do you want to start a new game?", "Query", MessageBoxButtons.YesNo);
switch (res)
{
case DialogResult.Yes:

MyAgent.ConnectionPool[EServiceType.QuBICAgent].RequestToPlayGame();

// MyAgent.ConnectionPool[EServiceType.Avatar].Ping(EServiceType.CyberneticEnvironment);

MyAgent.ConnectionPool[EServiceType.Avatar].RequestToPlayGame();
MyAgent.ConnectionPool[EServiceType.Referee].RequestToPlayGame();


MessageBox.Show("I have requested the game to all players and referee");
break;
case DialogResult.No:
MessageBox.Show("No new game can start");
break;
}
}
else
{
MessageBox.Show("Cybernetic Environment Firstly should be connect to the Task Manager");
}

}
private void CyberneticEnviornmentWnd_Load(object sender, EventArgs e)
{
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}


}
}

推荐答案

未找到端点异常意味着它所说的内容.客户端找不到指定的终点.确保-

1.终点地址正确.
2.服务器已启动并且正在运行,并且您的WCF服务可用
3.如果您的服务已更新,则端点mcght已更改.确保您具有指向最新更新服务的代理.您可以尝试重新创建一个新的代理,然后重试.
4.您可能还想研究客户的特权.也就是说,您的客户应具有足够的特权来访问您的服务.

希望这会有所帮助.
End Point not found exception means exactly what it says. The client cannot find the end point that is specified. Make sure -

1. The end point address is correct.
2. The server is up and running and your WCF service is available
3. The endpoint mcght have changed if your service was updated. Make sure you have the proxy pointing to the latest updated service. You can try and recreate a new proxy and try again.
4. You might also want to look into the privilege of your client. i.e. your client should have enough privilege to access your service.

Hope this helps.


这篇关于WCF c#.net中的EndPointNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆