tags:

views:

117

answers:

3

User starts up a silverlight application in their browser by navigating to a given URL.

User then opens another browser and starts up the same silverlight application by navigating to the same URL.

Can the second instance of the application detect that there is already an instance running on the same computer?

Can it detect itself if both applications are running within the same browser instance?

I would expect the answer to be 'no' but thought that i would ask it anyway. Otherwise i believe that i will have to setup a webservice and have each instance register itself and send requests to other instances from the same IP. does that sound reasonable?

A: 

I think you're right you can't do it cross-application, but you can do it within a single browser instance using cookies or Isolated Storage.

Matthew Flaschen
+2  A: 

I think you may be looking for LocalMessageSender and LocalMessageReceiver. I believe these are new classes in Silverlight 3 allowing two Silverlight applications running on the same local computer to communicate.

More detail: Communication Between Local Silverlight-Based Applications (msdn)

ChronoPositron
+2  A: 

This will work, I've done it myself. This code from the Microsoft site demonstrates how you set up a LocalMessage 'receiver". If it throws an error, it is because another instance of the Silverlight app is already running.

    public Receiver()
    {
        InitializeComponent();

        LocalMessageReceiver messageReceiver =
            new LocalMessageReceiver("receiver",
            ReceiverNameScope.Global, LocalMessageReceiver.AnyDomain);
        messageReceiver.MessageReceived += messageReceiver_MessageReceived;
        try
        {
            messageReceiver.Listen();
        }
        catch (ListenFailedException)
        {
            output.Text = "Cannot receive messages." + Environment.NewLine +
                "There is already a receiver with the name 'receiver'.";
        }
    }
Michael Washington
Also this works not only on different web browsers (but on the same computer) but even if the person is logged into the site using remote desktop and also on their local computer.
Michael Washington