title: Error Object reference not set to an instance of an object on WCF Service
body: <p>I am currently developing a WCF Publish Subscribe service. My Service has the following code,</p>
  
  <pre><code>public void PublishPost(string postSampleData)
  {
      PostChangeEventArgs e = new PostChangeEventArgs();
      e.PostData = postSampleData;
      PostChangeEvent(this, e);
  }
  </code></pre>
  
  <p>and the code for the postChangeEvent is</p>
  
  <pre><code>public class PostChangeEventArgs : EventArgs
  {
      public string PostData;
  }
  </code></pre>
  
  <p>and in my client file, i wrote this code in the main method,</p>
  
  <pre><code>class Program : IPostingContractCallback
  {
  static void Main()
  {
          InstanceContext site = new InstanceContext(null, new Program());
          PostingContractClient client = new PostingContractClient(site);
  
          WSDualHttpBinding binding = (WSDualHttpBinding)client.Endpoint.Binding;
          String clientcallbackaddress = binding.ClientBaseAddress.AbsoluteUri;
          clientcallbackaddress += Guid.NewGuid().ToString();
          binding.ClientBaseAddress = new Uri(clientcallbackaddress);
  
          client.Subscribe();
  }
  
  public void PostReceived(string postSampleData)
  {
      MessageBox.Show("PostChange(item {0})", postSampleData);
  }
  }
  </code></pre>
  
  <p>and for the code for my data source...</p>
  
  <pre><code>class Program : IPostingContractCallback
  {
      static void Main(string[] args)
      {
          InstanceContext site = new InstanceContext(new Program());
          PostingContractClient client = new PostingContractClient(site);
  
          client.PublishPost("testing");
  
          Console.WriteLine();
          Console.WriteLine("Press ENTER to shut down data source");
          Console.ReadLine();
  
          //Closing the client gracefully closes the connection and cleans up resources
          client.Close();
      }
  
      public void PostReceived(string postSampleData)
      {
          Console.WriteLine("PostChange(item {0})",postSampleData);
      }
  }
  </code></pre>
  
  <p>After running the service, followed by the client, followed by the datasource, I'm suppose to receive a popup messagebox from my client. However there gives an error on the line</p>
  
  <pre><code>PostChangeEvent(this, e);
  </code></pre>
  
  <p>Object reference not set to an instance of an object.</p>
  
  <p>Anyone know how to solve this?</p>