EndPointNotFoundException in WCF c#.net

Discussion in 'C#' started by asmakhan, Oct 1, 2010.

  1. asmakhan

    asmakhan New Member

    Joined:
    Oct 1, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hello

    i have EndPointNotFoundException in wcf c#.net
    where the proxy is generated dynamically. and all clients are preconnected to the server. but the problem arise when server call the client fuctions.

    Code:
    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(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 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);
                            
                           [COLOR=Red] MyAgent.ConnectionPool[EServiceType.Avatar].RequestToPlayGame();[/COLOR]                        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)
            {
    
            }
        }
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice