Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF REST Starter Kit - A property with the name 'UriTemplateMatchResults' already exists
    primarykey
    data
    text
    <p>I just started with the WCF REST Starter Kit.</p> <p>I created a simple service that return an array of an object.</p> <p>Using the browser, everything works fine but when I use a WCF client, I get an ArgumentException.</p> <p>I'm not using IIS and here is the code:</p> <p><strong>The contract:</strong></p> <pre><code>[ServiceContract] public interface IGiftService { [WebGet(UriTemplate="gifts")] [OperationContract] List&lt;Gift&gt; GetGifts(); } public class GiftService : IGiftService { public List&lt;Gift&gt; GetGifts() { return new List&lt;Gift&gt;() { new Gift() { Name = "1", Price = 1.0 }, new Gift() { Name = "2", Price = 1.0 }, new Gift() { Name = "3", Price = 1.0 } }; } } [DataContract] public class Gift { [DataMember] public string Name { get; set; } [DataMember] public double Price { get; set; } } </code></pre> <p><strong>To start the service:</strong></p> <pre><code>WebServiceHost2 host = new WebServiceHost2( typeof(GiftService), true, new Uri("http://localhost:8099/tserverservice")); host.Open(); Console.WriteLine("Running"); Console.ReadLine(); host.Close(); </code></pre> <p><strong>To start the client:</strong></p> <pre><code>WebChannelFactory&lt;IGiftService&gt; factory = new WebChannelFactory&lt;IGiftService&gt;( new Uri("http://localhost:8099/tserverservice")); IGiftService service = factory.CreateChannel(); List&lt;Gift&gt; list = service.GetGifts(); Console.WriteLine("-&gt; " + list.Count); foreach (var item in list) { Console.WriteLine("-&gt; " + item.Name); } </code></pre> <p>The server and the client are in the same solution and I'm using the same interface in both (to describe the service contract).</p> <p>The exception says: "A property with the name 'UriTemplateMatchResults' already exists." and that is the stack trace:</p> <p><strong>Class firing the exception</strong> -> Microsoft.ServiceModel.Web.WrappedOperationSelector</p> <p><strong>Stack trace:</strong></p> <pre><code> at System.ServiceModel.Channels.MessageProperties.UpdateProperty(String name, Object value, Boolean mustNotExist) at System.ServiceModel.Channels.MessageProperties.Add(String name, Object property) at System.ServiceModel.Dispatcher.WebHttpDispatchOperationSelector.SelectOperation(Message&amp; message, Boolean&amp; uriMatched) at System.ServiceModel.Dispatcher.WebHttpDispatchOperationSelector.SelectOperation(Message&amp; message) at Microsoft.ServiceModel.Web.WrappedOperationSelector.SelectOperation(Message&amp; message) in C:\Program Files\WCF REST Starter Kit\Microsoft.ServiceModel.Web\WrappedOperationSelector.cs:line 42 at Microsoft.VisualStudio.Diagnostics.ServiceModelSink.ServiceMethodResolver.GetOperation() at Microsoft.VisualStudio.Diagnostics.ServiceModelSink.ServiceMethodResolver..ctor(ContractDescription contract, DispatchRuntime runtime, Message request, InstanceContext instanceContext) </code></pre> <p>What am I doing wrong?</p> <p><strong>UPDATE:</strong> I disabled the help page and the service is working now. Is it a bug?</p> <pre><code>host.EnableAutomaticHelpPage = false; </code></pre> <p>Thank you!</p> <p>André Carlucci</p>
    singulars
    1. This table or related slice is empty.
    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.
    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