Note that there are some explanatory texts on larger screens.

plurals
  1. POServiceHost only supports class service types
    primarykey
    data
    text
    <p>I have a service named WcfService2 (original i know) which has an IService.cs file with a public interface:</p> <pre><code>namespace WcfService2 { [ServiceContract] public interface IService1 { [OperationContract] [WebGet(UriTemplate = "/{value}")] string GetData(string value); } } </code></pre> <p>I then have my public class Service1.svc.cs file which returns a string for the value like so:</p> <pre><code>namespace WcfService2 { public class Service1 : IService1 { public string GetData(string value) { return string.Format("You entered: {0}", value); } } } </code></pre> <p>I am now trying to host this service with a console app like so:</p> <pre><code>namespace Host { class Program { static void Main(string[] args) { WebHttpBinding binding = new WebHttpBinding(); WebServiceHost host = new WebServiceHost(typeof(IService1)); host.AddServiceEndpoint(typeof(IService1), binding, "http://localhost:8000/Hello"); host.Open(); Console.WriteLine("I DONT LIKE REST!"); Console.WriteLine("Press &lt;RETURN&gt; to KILL REST FOR GOOD"); Console.ReadLine(); } } } </code></pre> <p>But I get an error after I run it:</p> <blockquote> <p>ServiceHost only supports class service types.</p> </blockquote> <p>So this obviously relates to my IService being of public interface type. But I dont know how else to create it, when I first created the <code>WCF Service application</code> it gives you the two standard files IService and Service.svc files if I delete either or, and only Implement this solution in one class when I try to add the web service in local soultion nothing is found.</p> <p>Is there a way to fiddle with the host code? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload