Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. what is the problem in this >>> see the code and pls help me

what is the problem in this >>> see the code and pls help me

Scheduled Pinned Locked Moved C#
helpcsharplinqsysadminquestion
10 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amaankhan
    wrote on last edited by
    #1

    remoting dll >>>> using System; using System.Collections; using System.Linq; using System.Text; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Http; namespace Remoting { public class ChatServer : MarshalByRefObject { ArrayList client = new ArrayList(); public void AddClient(string s) { client.Add(s); } public ArrayList AllClient() { return client; } } } Server code >>>>>>>> using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Http; using Remoting; namespace Server { public partial class Form1 : Form { ChatServer server; public Form1() { InitializeComponent(); HttpChannel ch = new HttpChannel(8080); ChannelServices.RegisterChannel(ch, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(ChatServer), "CS", WellKnownObjectMode.Singleton); } private void ShowClients_Click(object sender, EventArgs e) { server = new ChatServer(); ArrayList cn =server.AllClient(); foreach (string c in cn) { listBox1.Items.Add(c); } } } } client code >>>>> using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Http; using Remoting; namespace Client { public partial class Form1 : Form { ChatServer client; public Form1() { InitializeComponent(); HttpChannel ch = new HttpChannel(); ChannelServices.RegisterChannel(ch, false); RemotingConfiguration.RegisterWellKnownClientType(typeof(ChatServer), "http://localhost:8080/CS"); client = new ChatServer(); client.AddClient("AAA"); } } } >>>>>>>>> when i click on showclient its not showing ........ what is the problem. Thanks in Advance

    C 1 Reply Last reply
    0
    • A amaankhan

      remoting dll >>>> using System; using System.Collections; using System.Linq; using System.Text; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Http; namespace Remoting { public class ChatServer : MarshalByRefObject { ArrayList client = new ArrayList(); public void AddClient(string s) { client.Add(s); } public ArrayList AllClient() { return client; } } } Server code >>>>>>>> using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Http; using Remoting; namespace Server { public partial class Form1 : Form { ChatServer server; public Form1() { InitializeComponent(); HttpChannel ch = new HttpChannel(8080); ChannelServices.RegisterChannel(ch, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(ChatServer), "CS", WellKnownObjectMode.Singleton); } private void ShowClients_Click(object sender, EventArgs e) { server = new ChatServer(); ArrayList cn =server.AllClient(); foreach (string c in cn) { listBox1.Items.Add(c); } } } } client code >>>>> using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Http; using Remoting; namespace Client { public partial class Form1 : Form { ChatServer client; public Form1() { InitializeComponent(); HttpChannel ch = new HttpChannel(); ChannelServices.RegisterChannel(ch, false); RemotingConfiguration.RegisterWellKnownClientType(typeof(ChatServer), "http://localhost:8080/CS"); client = new ChatServer(); client.AddClient("AAA"); } } } >>>>>>>>> when i click on showclient its not showing ........ what is the problem. Thanks in Advance

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Have you stepped through the code ? Why on earth are you using the ArrayList class ? It's obsolete.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      A 1 Reply Last reply
      0
      • C Christian Graus

        Have you stepped through the code ? Why on earth are you using the ArrayList class ? It's obsolete.

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        A Offline
        A Offline
        amaankhan
        wrote on last edited by
        #3

        i am using arraylist to store all the clients name. i know its obsolete. well i can change it not a problem.... but what is the main problem why i am not getting the connected client when i am clicking on button showclient_click help me

        C 1 Reply Last reply
        0
        • A amaankhan

          i am using arraylist to store all the clients name. i know its obsolete. well i can change it not a problem.... but what is the main problem why i am not getting the connected client when i am clicking on button showclient_click help me

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Well, I don't know. I am just wondering if you can explain what you've done to help yourself, using the debugger,etc. If you can tell us what line of code isn't doing what you expect, it would help us to narrow it down, without having actually build your code and run a client/server to see what happens. Someone who has done more of this sort of work than me may come along and just answer it, but in the meantime, I think it's valuable to explore the things you should have mentioned in your original post, like what happens when you run it in the debugger.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          A 1 Reply Last reply
          0
          • C Christian Graus

            Well, I don't know. I am just wondering if you can explain what you've done to help yourself, using the debugger,etc. If you can tell us what line of code isn't doing what you expect, it would help us to narrow it down, without having actually build your code and run a client/server to see what happens. Someone who has done more of this sort of work than me may come along and just answer it, but in the meantime, I think it's valuable to explore the things you should have mentioned in your original post, like what happens when you run it in the debugger.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            A Offline
            A Offline
            amaankhan
            wrote on last edited by
            #5

            i have run debugger more then 5 times , but still not able to trace where is the problem....... its not showing any error.... but i am not getting the out put........ :(

            C A 2 Replies Last reply
            0
            • A amaankhan

              i have run debugger more then 5 times , but still not able to trace where is the problem....... its not showing any error.... but i am not getting the out put........ :(

              A Offline
              A Offline
              amaankhan
              wrote on last edited by
              #6

              Sir these what i have done 1. i made a dll remoting in which i had 2 methods AddClient and ALLClient 2. i made a server add reference of remoting.dll file and here i am calling the method allclient to view the clients connected to the server 3. i made a client add reference of remoting.dll file and here i am calling the method addclient. >>> anything wrong ?

              1 Reply Last reply
              0
              • A amaankhan

                i have run debugger more then 5 times , but still not able to trace where is the problem....... its not showing any error.... but i am not getting the out put........ :(

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                What makes you think that adding to the list in one program, will make it appear in the other one ?

                Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                A 1 Reply Last reply
                0
                • C Christian Graus

                  What makes you think that adding to the list in one program, will make it appear in the other one ?

                  Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                  A Offline
                  A Offline
                  amaankhan
                  wrote on last edited by
                  #8

                  sorry sir. i am just trying this way. when a client starts the applicationand connects the server i am calling a method Addclient(Sys.Env.MachineName) . and then on the server i want the name of the clients connected to the server.............. what i have done was wrong? :( sorry :( help me out

                  C 1 Reply Last reply
                  0
                  • A amaankhan

                    sorry sir. i am just trying this way. when a client starts the applicationand connects the server i am calling a method Addclient(Sys.Env.MachineName) . and then on the server i want the name of the clients connected to the server.............. what i have done was wrong? :( sorry :( help me out

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #9

                    You have two instances of the same class type. They are on different machines. They are not the same instance, nor can they be. Therefore, passing the value to one, does not pass it to the other. At least, that's how it looks to me.

                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                    A 1 Reply Last reply
                    0
                    • C Christian Graus

                      You have two instances of the same class type. They are on different machines. They are not the same instance, nor can they be. Therefore, passing the value to one, does not pass it to the other. At least, that's how it looks to me.

                      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                      A Offline
                      A Offline
                      amaankhan
                      wrote on last edited by
                      #10

                      sir then how to do that. :( cann't i call a method from the server and used it in the client ?

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups