Parametrized Threads in Windows Server 2003 R2

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JSan
    New Member
    • Jun 2010
    • 4

    Parametrized Threads in Windows Server 2003 R2

    Hi all, I've been working on an .net application which starts different instances of a class, each one contains a main thread (it's a TcpListener). The application so far in the development PC (WinXP SP3 Pro, VS2008, .net Framework 3.5 SP1) works very nice, but when i move it to the destination machine (Windows Server 2003 R2, .net Framework 3.5 SP1) it just doesn´t works. I've tracked the error to the main thread in each one of the instances, and is caused because i read the Parameters passed to the thread itself! Someone has an idea about what could i've been missing? Thanks in advance.

    Thread initialization:
    Code:
    ListeningThread = new Thread(new ParameterizedThreadStart(ServerThread));
    ListeningThread.Name = "ListeningThread";
    ListeningThread.IsBackground = true;
    ThreadList.Add(ListeningThread);
     
    myLog.Add("Thread de servidor lanzado");
                     
    string Data = ListeningIP.ToString() + ":" + Port.ToString();
    ListeningThread.Start((object)Data);
    Thread itself
    Code:
    public void ServerThread(object EndPoint) //EndPoint = IP:Puerto (en string)
    {
    // Crea un socket TCP/IP (IPv4) y escucha por conexiones.
    try
    {
        string Parametros = (string)EndPoint;
        myLog.Add("--ThID:{" + Thread.CurrentThread.ManagedThreadId.ToString() + "}Datos recibidos en el thread: " + (string)EndPoint);
     
        string[] Datos = Parametros.Split(':');
        if (Datos.Length < 2)
           throw new Exception("Error en parametros");
        System.Net.IPAddress LocalIP = System.Net.IPAddress.Parse(Datos[0]);
        int LocalPort = Int32.Parse(Datos[1]);
        myLog.Add("--ThID:{" + Thread.CurrentThread.ManagedThreadId.ToString() +  "}--Entrando a Thread de Servidor--");
        myLog.Add("--ThID:{" + Thread.CurrentThread.ManagedThreadId.ToString() + "}--IP para escuchar: " + LocalIP.ToString() + ":" + LocalPort.ToString());               
       
     
        TcpListener listener = new TcpListener(LocalIP, LocalPort);
        myLog.Add("--ThID:{" + Thread.CurrentThread.ManagedThreadId.ToString() + "} Datos Listener" + listener.LocalEndpoint.ToString());                  
        listener.Start();
    .....
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    What is the exact error message you get?
    Is it possible its a priveledge issue?(You are moving from a non-server to a server OS so things might be different with the priveledges)

    Comment

    • JSan
      New Member
      • Jun 2010
      • 4

      #3
      Well, i´m logging in as Administrator, and the problem is very weird, te first times tha app just ended with no messagebox or error logged, but i noticed that DW20.exe (Doctro Watson for Office)started just before the application crashed so i rename DW20.exe. Now i can see a Message Window but the message doesn't display any useful info, just says: "Tha application XXXX encountered a problem... ThreadID(0x23CC )" so i don't have any more info. Thanks

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        That sounds like an unmanaged exception.
        UNLESS there was a "details" or "see what this report contains" type link/button(could be a text link like on a webpage would be or maybe a regular button). Sometimes in there it will tell you the managed exception that is coming up.

        Comment

        Working...