Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a windows application(A), WCFService Library, WCFServiceApplication in my solution.

From windows application, when I hit submit, I can get data displayed on label.

Now what should I do to send the data from another application(Windows Application B) button click.

Here is code for Windows Application Form:

C#
private void btnMainWindow_Click(object sender, EventArgs e)
        {
            ChannelFactory<IService1> factory = null;
            try 
            {
                BasicHttpBinding binding = new BasicHttpBinding();
                EndpointAddress address = new EndpointAddress("");
                factory = new ChannelFactory<IService1>(binding, address);
                IService1 channel = factory.CreateChannel();
                
            }
            catch (CommunicationException ex)
            {
                //Console.WriteLine(ex);
                if (factory != null)
                    factory.Abort();
            }
            catch (TimeoutException)
            {
                if (factory != null)
                    factory.Abort();
            }
            catch (Exception ex)
            {
                if (factory != null)
                    factory.Abort();
                //Console.WriteLine(ex.Message);
            }
            MessageBox.Show("Proxy closed");
        }


My Interface

C#
[ServiceContract]
    public interface IMyService
    {
        [OperationContract]
        string GetData(int value);
    }



C#
public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }


What I have tried:

I took both WCFService Library and WCFServiceApplication because, I didn't add Service Reference.
Posted
Updated 19-May-16 9:38am

1 solution

Something like this, if the components are on the same machine you can use named pipes:
C#
using (ServiceHost host = new ServiceHost(
      typeof(GetData),
      new Uri[]{
        new Uri("http://localhost:8000"),
        new Uri("net.pipe://localhost")
      }))


This is the simplest example I could find: WCF Tutorial - Basic Interprocess Communication - Tech.pro[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900