locked
Consuming WCF service produces error RRS feed

  • Question

  • Hello,

    I've configured a WCF service to be hosted when my MVC4 application starts. This all works up until the point where I invoke the service

    namespace DataService
    {
    	[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    	public class MyService: DataService<TestDb>
    	{
    		public static void InitializeService(DataServiceConfiguration config)
    		{
    			config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
    			config.SetServiceOperationAccessRule("*", ServiceOperationRights.AllRead);
    
    			config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
    
    			config.DataServiceBehavior.AcceptAnyAllRequests = true;
    			//config.DataServiceBehavior.AcceptCountRequests = true;
    			//config.DataServiceBehavior.AcceptProjectionRequests = true;
    			config.UseVerboseErrors = true;
    		}
    
    		protected override TestDbCreateDataSource()
    		{
    			return new TestDb("TestDb");
    		}
    	}
    }

    http://localhost:4040/MyService/

    This then produces the following error:

    The server encountered an error processing the request. The exception
    message is 'Expression of type 'System.Void' cannot be used for return
    type 'System.Int32''. See server logs for more details. The exception
    stack trace is:

       at
    System.Linq.Expressions.Expression.ValidateLambdaArgs(Type delegateType,
    Expression& body, ReadOnlyCollection`1 parameters)
       at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression
    body, String name, Boolean tailCall, IEnumerable`1 parameters)
       at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression
    body, Boolean tailCall, IEnumerable`1 parameters)
       at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression
    body, ParameterExpression[] parameters)
       at
    System.Data.Services.Providers.DbContextHelper.CreateDbContextAccessor(Type
    type)
       at
    System.Data.Services.Providers.DbContextHelper.GetDbContextAccessor(Type
    type)
       at
    System.Data.Services.Providers.DbContextHelper.IsDbContextType(Type
    type)
       at
    System.Data.Services.DataService`1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider&
    metadataProviderInstance, IDataServiceQueryProvider&
    queryProviderInstance, Object& dataSourceInstance, Boolean&
    isInternallyCreatedProvider)
       at System.Data.Services.DataService`1.CreateProvider()
       at
    System.Data.Services.DataService`1.EnsureProviderAndConfigForRequest()
       at System.Data.Services.DataService`1.HandleRequest()
       at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream
    messageBody)
       at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] )
       at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object
    instance, Object[] inputs, Object[]& outputs)
       at
    System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&
    rpc)
       at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&
    rpc)
       at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&
    rpc)
       at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
    rpc)
       at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&
    rpc)
       at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&
    rpc)
       at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&
    rpc)
       at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&
    rpc)
       at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&
    rpc)
       at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean
    isOperationContextSet)

    Thursday, November 14, 2013 3:15 PM