locked
How to debug and trace customized WCF Data Service? RRS feed

  • Question

  • I customized WCF data service by overriding CreateDataSource method. I put some debug message like System.Diagnostics.Debug.WriteLine(...) in CreateDataSource method. This method should be called during each request. However, when I ran the Url http://localhost/MyDataService/DataService.svc/Companies?$select=CompanyName, the data service returned correct data, but there was no debug messages in DebugView.

    How can I debug and step in CreateDataSource method? Why debug messages didn't show in DebugView?

    Thanks in advance!!!

    Thursday, March 27, 2014 9:50 PM

Answers

  • I figured it out. After clicking F5 to let my data service run without any parameters, I modify my URL to add query expression in the same browser. The overrided method can be debugged step by step.

    Now I can debug. Thanks!!!

    • Marked as answer by s liu Monday, March 31, 2014 8:47 PM
    Monday, March 31, 2014 8:47 PM

All replies

  • Hello s liu,

    The WCF Data Service is actually a service, when we want to debug a service, we need to start up it firstly. For example, if your WCF Data Service is host on WCF Application project, please press F5. For this, you can check the below gif:

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 28, 2014 1:50 AM
    Moderator
  • My WCF data service is hosted in IIS. I did try to start WCF data service by clicking on Start button on VS 2012. It starts IE using IIS Express. But there is no query string attached. If I starts a new IE browser with similar URL with query string expression, my breakpoints never been hit.

    If I configure the project not using IIS Express, when Start button clicked, IE returns the following:

    The resource cannot be found.
    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /MyDataService/DataService.svc


    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18067

    Friday, March 28, 2014 5:54 PM
  • Hi,

    I am confused why it will happen that and the “by clicking on Start button on VS 2012.”, you can see that in my test, I click the Internet Explorer, and it can go into the overrided method.

    I upload my project to skydrive, you can download it and test it, for the database, you can generate them using the model.

    By the way, I suggest you posting issue to IIS forum since it is host on IIS and there are IIS experts who may know how to debug a service with IIS.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 31, 2014 6:58 AM
    Moderator
  • In VS 2012, I set my WCF data service as Startup project. “by clicking on Start button on VS 2012.” is F5 button. After clicking on F5, it did go into the overrided method, but without OData query expression like $select=Product.

    So after WCF data service is running by clicking F5, I start a brand new IE browser and pasted in the previous URL with OData query expression. In this case, it didn't go into the overrided method. I want to debug the method when there is some query expressions in URL.

    Hope this will clarify what I'm trying to do.

    Thanks!

    Monday, March 31, 2014 4:41 PM
  • I figured it out. After clicking F5 to let my data service run without any parameters, I modify my URL to add query expression in the same browser. The overrided method can be debugged step by step.

    Now I can debug. Thanks!!!

    • Marked as answer by s liu Monday, March 31, 2014 8:47 PM
    Monday, March 31, 2014 8:47 PM