locked
How to troubleshoot error 500? RRS feed

  • Question

  • [ServiceBehavior(IncludeExceptionDetailInFaults = true)]  
        public class StoreService : DataService<StoreContext>
        {
            public static void InitializeService(DataServiceConfiguration config)
            {
                config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
                config.UseVerboseErrors = true;
                config.SetEntitySetAccessRule("Categories", EntitySetRights.AllRead);
                config.SetEntitySetAccessRule("Orders", 
    }
    

     

    Where StoreContext is EF 4.1 Code First:

    public class StoreContext : DbContext
    {
            public DbSet<Order> Orders { get; set; }
    }
    
    


    Produces in the browser:

    ==

    The server encountered an error processing the request. The exception message is 'Exception has been thrown by the target of an invocation.'. See server logs for more details. The exception stack trace is:

    at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType

    ===

    I've seen many posts about the problem and the only resolustion so far has been to check syntax and try including or excluding certain entities to maybe narrow it down. Well, I've done all that and now I am at the point where I know what entity causes this, but have no way of resolving it.. Fidler is not much help either as it captures the same message in the response.

    Isn't there a way to debug it? Where are these server logs with "more details"? What else can be turned on to get additional information?

    -Stan

     

    Wednesday, December 21, 2011 3:42 PM

All replies

  • The easiest way is to attach a debugger to the service and let it stop on exceptions. You should the exception being thrown, then you should get more info about it. Also the above is not a complete error, If there's an invocation exception there should be an inner exception which is the actual problem.

    What version of WCF DS are you using? The RTM version doesn't work out of the box with CodeFirst.

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, December 21, 2011 4:19 PM
    Moderator
  • Ok, after attaching to the service process I get "The given name 'Orders' was not found in the entity sets.\r\nParameter name: name". This is better, however Orders is defintely there:

     

    public DbSet<Order> Orders { get; set; }
    

    and

     

     

    config.SetEntitySetAccessRule("Orders", EntitySetRights.All);
    


    and I am still not sure why framework does not find Orders.. Could it be because it derives from another class:

     

    public class Order : OrderBase
        {
    //...
    }

    I can expose OrderBase, but not Order..

     

    There is no inner exception in the stack trace.

    I have  "WCF Data Services Mar 2011 CTP2" and EF 4.1.

    Can you tell what version supports CodeFirst?

    -Stan

     

     


    • Edited by Stan B Wednesday, December 21, 2011 4:58 PM
    Wednesday, December 21, 2011 4:50 PM
  • Take a look at this page, it might not be exactly what you're trying to do, but the same trick (DataService<ObjectContext>, override CreateDataSource) should work.

    http://social.technet.microsoft.com/wiki/contents/articles/5234.aspx

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, December 21, 2011 6:00 PM
    Moderator
  • No, unfortunately overriding CreateDateSource did not help. CreateDataSource is being called, but it bombs on

     

    config.SetEntitySetAccessRule("Orders", EntitySetRights.All);
    

    All other entities are fine, except this one and it seems this happens because it derives from OrderBase:

     

    public class Order : OrderBase
        {
    ///
    }
    

    No does it work for another entity which also derives from OrderBase:

    public class Basket : OrderBase
        {        
        }


    I also upgraded to June 2011 CTP of both EF and DS, which I believe is the latest and greatest..

     

    -Stan


    • Edited by Stan B Thursday, December 22, 2011 9:16 PM
    Thursday, December 22, 2011 9:09 PM
  • The latest CTP is from November: http://blogs.msdn.com/b/astoriateam/archive/2011/10/13/announcing-wcf-data-services-oct-2011-ctp-for-net-4-and-silverlight-4.aspx

    I don't know what's wrong with the above.

    If you can, please send the repro project to vitek . karas at microsoft dot com.

    Thanks,


    Vitek Karas [MSFT]
    Friday, December 23, 2011 5:41 AM
    Moderator
  • Vitek, repro is on its way. Thanks a lot!

    -Stan

    Friday, December 23, 2011 4:57 PM