I'm getting a very strange error when I try to run svcutil.exe on a WCF service.
"OperationBehaviorAttribute can only go on the service class"
[InvalidOperationException]: OperationBehaviorAttribute can only go on the service class, it cannot be put on the ServiceContract interface. Method 'EditProduct' on type 'IProductWCF' violates this."
I have pasted my code below and if anybody can shed any light on this, I'd really appreciate it.
I should point out that it works on every method except "EditOpportunityProductTypes"
My Interface:
namespace ProductWCF { [ServiceContract] public interface IProductWCF { [OperationContract] string SayHello(AppointmentFeedback objAppointmentFeedback); [OperationContract] Boolean CreateAppointmentFeedback(AppointmentFeedback objAppointmentFeedback); [OperationContract] List<ExpiringContractType> GetOpportunityProductTypes(int opportunityId); [OperationBehavior] Boolean EditOpportunityProductTypes(List<ExpiringContractType> lstExpiringContractTypes, int opportunityId); } } My Service:
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) > 0) return true; else return false; } [OperationBehavior] public List<ExpiringContractType> GetOpportunityProductTypes(int opportunityId) { return OpportunityProductTypeMethods.GetOpportunityConnectionTypes(opportunityId); } [OperationBehavior] public Boolean EditOpportunityProductTypes(List<ExpiringContractType> lstExpiringContractTypes, int opportunityId) { return ProductData.CRM.Objects.OpportunityProductTypeMethods.UpdateOpportunityConnectionTypes(lstExpiringContractTypes, opportunityId); } } }