title: Visual Studio 2012 + IIS 8.0 = how to deploy WCF service on localhost?
body: <p>I have a <code>Wcf Service Application</code> project that is referenced by and used in different projects. Everything works fine when started Visual Studio 2012 - IIS Express is launched, hosted on localhost.</p>
  
  <p>I tried to use <code>Publish</code> option in right-click menu of my <code>Wcf Service Application</code>. I created a new profile for publishing:</p>
  
  <p><img src="https://i.stack.imgur.com/mgNnH.jpg" alt="Connection settings">
  <img src="https://i.stack.imgur.com/Bmcc0.jpg" alt="Settings"></p>
  
  <p>Hitting <code>Publish</code> works. I can access it through internet browser through <code>http://localhost</code>. However, when I launch my application normally, through the executable in bin/Debug - it doesn't work (app crashes). What should I do? Can I upload it and configure it easily with IIS Manager (tried it, but get some access errors)? I would need that in my virtual machine which doesn't have any VS installed.</p>
  
  <p>What's troubling me is that in my <code>Wcf Service Application</code> project's <code>Web.config</code> file I have base addresses specified like this: <code>http://localhost:8733/WcfServiceLibrary/MailingListService/</code> and in clients <code>App.config</code> I have endpoints with addresses like this: <code>http://localhost/MailingListService.svc</code>. Is it ok to have different ports and addresses (one is in root, the other in <code>WcfServiceLibrary</code>)? It works fine when run in Visual Studio.</p>
  
  <p><code>Web.config</code>:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;connectionStrings&gt;
      &lt;add name="NewsletterEntities" connectionString="metadata=res://*/NewsletterDAL_EF.csdl|res://*/NewsletterDAL_EF.ssdl|res://*/NewsletterDAL_EF.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;Data Source=(local)\SQLEXPRESS;Initial Catalog=Newsletter;Integrated Security=True;Pooling=False;MultipleActiveResultSets=True&amp;quot;" providerName="System.Data.EntityClient"/&gt;
    &lt;/connectionStrings&gt;
    &lt;appSettings&gt;
      &lt;add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /&gt;
    &lt;/appSettings&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5" /&gt;
      &lt;httpRuntime targetFramework="4.5"/&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;services&gt;
        &lt;service name="WCFHost.MessageService"&gt;
          &lt;endpoint address="" binding="basicHttpBinding" contract="WCFHost.IMessageService"&gt;
            &lt;identity&gt;
              &lt;dns value="localhost" /&gt;
            &lt;/identity&gt;
          &lt;/endpoint&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:8733/WcfServiceLibrary/MessageService/" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
        &lt;service name="WCFHost.MailingListService"&gt;
          &lt;endpoint address="" binding="basicHttpBinding" contract="WCFHost.IMailingListService"&gt;
            &lt;identity&gt;
              &lt;dns value="localhost" /&gt;
            &lt;/identity&gt;
          &lt;/endpoint&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:8733/WcfServiceLibrary/MailingListService/" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
        &lt;service name="WCFHost.RecipientService"&gt;
          &lt;endpoint address="" binding="basicHttpBinding" contract="WCFHost.IRecipientService"&gt;
            &lt;identity&gt;
              &lt;dns value="localhost" /&gt;
            &lt;/identity&gt;
          &lt;/endpoint&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:8733/WcfServiceLibrary/RecipientService/" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
        &lt;service name="WCFHost.SenderService"&gt;
          &lt;endpoint address="" binding="basicHttpBinding" contract="WCFHost.ISenderService"&gt;
            &lt;identity&gt;
              &lt;dns value="localhost" /&gt;
            &lt;/identity&gt;
          &lt;/endpoint&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:8733/WcfServiceLibrary/SenderService/" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior&gt;
            &lt;!-- To avoid disclosing metadata information, set the values below to false before deployment --&gt;
            &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/&gt;
            &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;protocolMapping&gt;
          &lt;add binding="basicHttpsBinding" scheme="https" /&gt;
      &lt;/protocolMapping&gt;    
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
      &lt;!--
          To browse web app root directory during debugging, set the value below to true.
          Set to false before deployment to avoid disclosing web app folder information.
        --&gt;
      &lt;directoryBrowse enabled="true"/&gt;
    &lt;/system.webServer&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p><code>App.config</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;startup&gt; 
          &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /&gt;
      &lt;/startup&gt;
      &lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;basicHttpBinding&gt;
                  &lt;binding name="BasicHttpBinding_IMessageService" /&gt;
                  &lt;binding name="BasicHttpBinding_IRecipientService" /&gt;
                  &lt;binding name="BasicHttpBinding_IMailingListService" /&gt;
                  &lt;binding name="BasicHttpBinding_ISenderService" /&gt;
              &lt;/basicHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;client&gt;
              &lt;endpoint address="http://localhost:2433/MessageService.svc"
                  binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMessageService"
                  contract="MessageServiceReference.IMessageService" name="BasicHttpBinding_IMessageService" /&gt;
              &lt;endpoint address="http://localhost/RecipientService.svc"
                  binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRecipientService"
                  contract="RecipientServiceReference.IRecipientService" name="BasicHttpBinding_IRecipientService" /&gt;
              &lt;endpoint address="http://localhost/MailingListService.svc"
                  binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMailingListService"
                  contract="MailingListServiceReference.IMailingListService"
                  name="BasicHttpBinding_IMailingListService" /&gt;
              &lt;endpoint address="http://localhost/SenderService.svc" binding="basicHttpBinding"
                  bindingConfiguration="BasicHttpBinding_ISenderService" contract="SenderServiceReference.ISenderService"
                  name="BasicHttpBinding_ISenderService" /&gt;
          &lt;/client&gt;
      &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>