.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

TCP Client connecting to a dynamic ip - exception thrown

Posted By:      Posted Date: September 26, 2010    Points: 0   Category :.NET Framework

Im making a simple chat server for quite some time now and Im constantly having some easy problems I cant comprehend.

      client = new TcpClient();
      client.Connect(IPAddress.Parse(""), 15555);
It throws:
"A connection attempt failed because the connected party did not properly respond after a period of time, <br/>
or established connection failed because connected host has failed to respond"

Im connecting to myself over the internet I suppose but it wont work.

The thing is, Im not listening to this IP. Im listening to my LAN IP because Im connected to the internet through LAN so I cant listen to my global IP

because it throws an exception that the IP is not valid.

I suppose the real question is am I doing this right, and if not, what should i do?

View Complete Post

More Related Resource Links

Exception thrown on client proxy call to open

Exception thrown System.InvalidOperationException: The communication object cannot be modified while it is in the Opened state.

The following code throws this exception:

                if (dataAcesssProxy == null)
                    dataAcesssProxy = new CompetellaDataAccessService.CompetellaDataAccessClient();
                    dataAcesssProxy.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("someuser", "password", "domain");

                    dataAcesssProxy.InnerChannel.Faulted += new EventHandler(InnerChannel_Faulted);

Dynamic Checkboxlist exception when adding to Panel when using Master Page


In essence, I am creating Dynamic Checkboxlist controls and adding them to a Panel.  It works well when I do not have a Master Page configure to this webpage. Once I have a masterpage congifured.. I get a "Object Reference not set to instance of object" error on the Panel_Control.Controls.Add(Checkboxlistnew) line:

protected void Page_PreInit(object sender, EventArgs e)
        XML OXML = new XML();
        alistChkBoxLabels = OXML.XMLTransform("C:\\Documents and Settings\..\\Config_new.xml", "config_options/check_box/applications/app/@name");
        int count = 1;
        alistCheckisFacility = new ArrayList();
        alIDTracker = new ArrayList();
        while (count <= alistChkBoxLabels.Count)

            Checkboxlistnew = new CheckBoxList();
            Checkboxlistnew.ID = count.ToString();
            Checkboxlistnew.Items.Add(new ListItem(alistChkBoxLabels[count - 1].ToString(), alistChkBoxLabels[count - 1].ToString()));

            String sAppName = alistChkBoxLabels[count - 1].ToString().Trim();

            alistCheckisFacility = OXML.XMLTransform("C:\\Documents and Settings\\Administrator\\My Documents\\Visual Studio 2005\\WebSites\\User_Trial\\Config_new

Connection problem while connecting from client to server.

Hello, i am trying to connect sql server 2005 express using c#.net 3.5. my connection string is "Server=.\SQLExpress;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\db_naren.mdf;Database=db_naren; Trusted_Connection=Yes;" this is working fine when i am connecting to sql server from the local machine. When i am trying to connect from someother machine to server it is giving error like A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) i added previliges in add new administrator on SQL Server 2005 Surface Area Configuration . and i made changes on SQL Server 2005 Surface Area Configuration  page, on Database Engine --> Remote Connections -->Local and remote connections --> Using both TCP/IP and named pipelines. still same error i am getting from client machine i am using connection string as "Server=MyServer\SQLExpress;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\db_naren.mdf;Database=db_nare; Trusted_Connection=Yes;" is there any thing i need to do to connect from client machine to server?please

C# Client App connecting to WSS3.0 with X.509 certificate

I have been unable to find much information on using smart cards and X.509 certificates when connecting to WSS 3.0.  I am able to build a Web Service Reference in VS 2010 just fine.  I get prompted for my cert, I select it, enter my pin and all is well.  But I am failing to handle it properly in my app.  I created a test method that creates the new WSS List object.  I assign System.Net.Credentials.DefaultCredentials to the Credentials. I then call GetListCollection.  I am never prompted for my cert, and I get a 500 error back from the server.  Everything works fine in IE and adding the reference so I think I missed a step, but I cannot figure out what that would be. I running the app with an account that has no relationship to the authentication domain WSS is part of, so I expected to be prompted for the cert when I tried to connect. Does anyone know how to do this, or offer up some guidance.  Thanks, LD

client socket connecting in loop

I'm running Visual Studio Express 2008 C++ on a Windows XP machine. In trying to use System::Net TCP communication I came upon the following problem ... I'm connecting to a server by trying clientSocket->Connect() in a loop, because I need to wait until the server is up. If the connection fails, I just use an empty catch. I assume this is not really a good way to do it (giving catch functionality). using namespace System::Net; ... bool is_onLine = false; Socket clientSocket; ... while(!is_onLine){ try{ this->clientSocket->Connect(serverIpEndpoint); if (clientClientSocket->Connected){ // Print out connection succeeded is_onLine = true; } else{ is_onLine = false; } } catch (SocketException^ err){ } } I can't seem to do this any other way. Not having a catch makes the program throw an exception whenever I set up my client to use Socket->Connect() when the server is not running. Is there a better way to have the client trying to connect to the server in a loop?

Exception of type 'System.ExecutionEngineException' was thrown.

Hi,       I am showing a WPF Window as ShowDialog().  Before loading the window, we are showing a message box. Upon Pressing Cancel Button from the Message box, Application throws "Exception of type 'System.ExecutionEngineException' was thrown.".. While cancelling, Events are raised to close the Window.. If we comment that code, window will be in the open state, other wise will "Throw the error". Please help me!!!!!!!!!  

Exception has been thrown by the target of an invocation.

hi!! i am new to this,please help me with this when i use this,,,,image.Source = new BitmapImage(new Uri(str, UriKind.RelativeOrAbsolute));  it is working but when i use array of images and use  image[0].Source = new BitmapImage(new Uri(str, UriKind.RelativeOrAbsolute)); it gives me error  Exception has been thrown by the target of an invocation.   thanks

Kerberos Authentication with WCF Client Fault Exception

Hello, I am using Kerberos as the Authentication mode for a WCF Client to interact with an ASMX Web Service. I am using customBinding in the WCF Client. I am getting the below mentioned Fault Exception when I invoke the HelloWorld Method by creating a Proxy using SVCUTIL.   System.Web.Services.Protocols.SoapHeaderException: Server unavailable, please try later ---> System.ApplicationException: WSE841: An error occured processing an outgoing fault response. ---> System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: WSE914: This instance of derived key token does not support encryption, decryption, or key wrapping. It can only be used to sign or verify signature. Please make sure that the length of the derived key matches the length of the key required by the symmetric encryption algorithm configured for the derived key token manager.    at Microsoft.Web.Services3.Security.Tokens.DerivedKeyToken.Psha1SymmetricKeyAlgorithm.get_EncryptionFormatter()    at Microsoft.Web.Services3.Security.EncryptedData.ResolveDecryptionKey(String algorithmUri, KeyInfo keyInfo)    at Microsoft.Web.Services3.Security.EncryptedData.Decrypt(XmlElement encryptedElement)    at Microsoft.Web.Services3.Security.EncryptedData.Decrypt() &nbs

Application Exception Rule Violation thrown on Delete

I basically have my first simple asp.net MVC 2.0 web application up and running except for deletes. I tried to do the first delete today, but it throws an exception with the text Rules Violation.  I'm not sure what is causing the error however.It shouldn't be the database (I don't think) because when I trace the database, I never see the delete call and after having it fail, I was able to sucessfully run:DELETE FROM [Work] WHERE work_id = 84 GOCurrently this is my method (yes its primitive, but I was just trying to get it working), its the db.SubmitChanges() line where the application exception gets thrown. [HttpPost] public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here var result = db.Works.SingleOrDefault(w => w.work_id == id); if (result == null) return View("NotFound"); db.Works.DeleteOnSubmit(result); db.SubmitChanges(); return RedirectToAction("Index"); } catch { var result = db.Works.SingleOrDefault(w => w.work_id == id); return View(result); } } }This may be a Linq-to-Sql issue as this is really the first time I've us

Exception of type 'System.OutOfMemoryException' was thrown.

Hi, i am just using select stmt from some view. view defination is also selecting columns from inner join of 3 tables. view count is about 46 millions records. so while selecting from view it gives me: Exception of type 'System.OutOfMemoryException' was thrown. same error occur if i use direct select from those tables instead of select * from view. What is the reason behind this. Any help will be appreciated. Thanks Punia

Web Client Exception

Hi, Every time I try do Download a File Using the WebClient it Keeps Throwing this exception: WebException was Unhandled An exception occurred during a WebClient request. I tried Different Files and it keeps throwing that. Plz help! I'm Using WPF in C#

ASP.net UPS void wsdl error message 'exception has been raised as a result of client data'


exception has been raised as a result of client data. at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol

Void shipment erro message; I can't determine how to resolve error.  at ***

The following is the code for ups void shipment wsdl...

protected void wsdlRate()


RateWSs.RateRequest rateReq = new RateRequest();RateWSs.UPSSecurity rateSecurity = new RateWSs.UPSSecurity(); RateWSs.UPSSecurityServiceAccessToken rateToken = new RateWSs.UPSSecurityServiceAccessToken

Exception when access to sharepoint by Client Object Model


Hello ,

  - I have a windows Application .

  - In the  Form  load , I write the following code to aceess sharepoint site :

      ClientContext clientContext = new ClientContext("URL");

     Web site = clientContext.Web;



    MessageBox.Show("Title: {0}", site.Title);

  The following exception happened when execute query :

         "The re

need help about Exception of type 'System.Web.HttpUnhandledException' was thrown.

Hi Friends

I am developing a website in which i am using services of a third party service providers. after some transactions on their pages they are transfering control to my page say page1.aspx. 

But when the control is transfered to my page there is an exception /Runtime error..

I am unable to trace this error. I had tried to log all the errors. Where I found this error.

3/19/2010 3:34:44 AM
Offending URL: http://www.mydomain.com/ThankYou.aspx Source: System.Web Message: Exception of type 'System.Web.HttpUnhandledException' was thrown. Stack trace: at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.thankyou_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\5910a9b6\ab96f081\App_Web_upsitg7y.0.cs:line 0
at System.Web.HttpApplication.CallHandlerEx

Exception thrown when handling Window.Loaded event


Why is the exception assistant not "fired" in a debugging session when a Window.Loaded eventhandler calls code which throws an exception ?
        private void Window_Loaded(object sender, RoutedEventArgs e)
            //Application.Current.DispatcherUnhandledException +=
               new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException);
            int a = 1;
            int b = 0;
            int c = a / b;

        void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)

Removing the comment signs (//) thus presenting an UnhandledException handler devinately makes the assistant "firing".
Is this behaviour by desi

Exception thrown from workflow



I got following exception in my workflow.

Type : System.Exception, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : #################(Exception Start)#####Transaction (Process ID 115) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.,
Workflow Manager,WFStart,0,
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.HasMoreRows()
   at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout)
   at System.Workflow.Runtime.Hosting.PersistenceDBAccessor.RetrieveStateFromDB(DbCommand command, Boolean checkOwnership, Guid instanceId)
   at System.Workflow.Runtime.Hosting.PersistenceDBAccessor.RetrieveInstanceState(Guid instanceStateId, Guid ownerId, DateTim

sql server setup has encountered the following error exception has been thrown by the target of an i


OS - Windows Web Server 2008 R2

Processor: Intel (R) Xeon (R) CPU 5160 @ 3.00 GHZ 2.99 GHZ (2 Processor)

RAM 16.0 GB

System Type;: 64 bit Operating System

Trying to Install SQL Server 2008 R2 Standard

I installed all necessary SP and .Net Framework as instrcted but setup bring up the above error.

Please help - ASAP.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend