title: StreamSocketListener Access denied
body: <p>What I am wanting to do is create a SocketStreamListener and connect to it (on localhost). Then connect to it and send it a message. Very simple stuff and it's all done <a href="http://code.msdn.microsoft.com/windowsapps/StreamSocket-Sample-8c573931" rel="nofollow">here in an official demo</a> but I want to understand it and use this logic in my own application.</p>
  
  <p><strong>The Problem</strong></p>
  
  <p>I have created a <strong>new Windows Metro C# application project</strong> and have this code to create a listener on my MainPage:</p>
  
  <pre><code>private void Button_Click(object sender, RoutedEventArgs e)
  {
      StreamSocketListener listener = new StreamSocketListener();
      greetingOutput.Text = "Hello, " + nameInput.Text + "!";
  }
  </code></pre>
  
  <p>but I get this error:</p>
  
  <blockquote>
    <p>An exception of type 'System.UnauthorizedAccessException' occurred in
    HelloWorld.exe but was not handled in user code</p>
    
    <p>WinRT information: At least one of either InternetClientServer or
    PrivateNetworkClientServer capabilities is required to listen for or
    receive traffic</p>
    
    <p>Additional information: Access is denied.</p>
    
    <p>If there is a handler for this exception, the program may be safely
    continued.</p>
  </blockquote>
  
  <p>The same code works in the official demo though.</p>
  
  <p>What am I missing?
  What am I doing wrong?</p>