Note that there are some explanatory texts on larger screens.

plurals
  1. POOperationBehaviorAttribute error when running svcutil.exe on WCF service
    text
    copied!<p>I'm getting a very strange error when I try to run svcutil.exe on a WCF service.</p> <blockquote> <p>"OperationBehaviorAttribute can only go on the service class"</p> <p>[InvalidOperationException]: OperationBehaviorAttribute can only go on the service class, it cannot be put on the ServiceContract interface. Method 'EditProduct' on type 'IProductWCF' violates this."</p> </blockquote> <p>I have pasted my code below and if anybody can shed any light on this, I'd really appreciate it.</p> <p>I should point out that it works on every method except "EditOpportunityProductTypes"</p> <p>My Interface:</p> <pre><code>namespace ProductWCF { [ServiceContract] public interface IProductWCF { [OperationContract] string SayHello(AppointmentFeedback objAppointmentFeedback); [OperationContract] Boolean CreateAppointmentFeedback(AppointmentFeedback objAppointmentFeedback); [OperationContract] List&lt;ExpiringContractType&gt; GetOpportunityProductTypes(int opportunityId); [OperationBehavior] Boolean EditOpportunityProductTypes(List&lt;ExpiringContractType&gt; lstExpiringContractTypes, int opportunityId); } } </code></pre> <p>My Service:</p> <pre><code>namespace ProductWCF { public class Service : IProductWCF { [OperationBehavior] public string SayHello(AppointmentFeedback objAppointmentFeedback) { return objAppointmentFeedback.Notes; } [OperationBehavior] public Boolean CreateAppointmentFeedback(AppointmentFeedback objAppointmentFeedback) { ProductData.CRM.Objects.AppointmentFeedback objNewAppointmentFeedback = new AppointmentFeedback(); if (objNewAppointmentFeedback.Insert(objAppointmentFeedback.AppointmentId, objAppointmentFeedback.StarId, objAppointmentFeedback.AppointmentStatusId, objAppointmentFeedback.Notes, objAppointmentFeedback.Creator, objAppointmentFeedback.AttendeeName) &gt; 0) return true; else return false; } [OperationBehavior] public List&lt;ExpiringContractType&gt; GetOpportunityProductTypes(int opportunityId) { return OpportunityProductTypeMethods.GetOpportunityConnectionTypes(opportunityId); } [OperationBehavior] public Boolean EditOpportunityProductTypes(List&lt;ExpiringContractType&gt; lstExpiringContractTypes, int opportunityId) { return ProductData.CRM.Objects.OpportunityProductTypeMethods.UpdateOpportunityConnectionTypes(lstExpiringContractTypes, opportunityId); } } } </code></pre>
 

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