Michael
Michael

Reputation: 421

Attempting to debug WCF Service added to a solution created with a MVVM Light Toolkit template fails

The goal here is to be able to step into the WCF service code, as well as the Silverlight app code.

  1. File new project > MvvmLight(SL4)
  2. Add new project > WCF Service app
  3. Add service ref to new service in SL proj

  4. In Model\DataService.cs replace GetData with the code below

    public void GetData(Action<DataItem, Exception> callback)
    {
        // Use this to connect to the actual data service
    
        //var item = new DataItem("Welcome to MVVM Light");
    
        var client = new ServiceReference1.Service1Client();
        client.GetDataCompleted += (s, e) =>
        {
            var userCallback = e.UserState as Action;
    
            var item = new DataItem(e.Result);
    
            userCallback(item, null);
        };
        client.GetDataAsync(123, callback);
    }
    
  5. Place a breakpoint in the GetData method of Service1.svc.cs

  6. F5 to start debugging.

You’ll get a dialog saying you can’t debug.

“The Silverlight project you are about to debug uses web services. Calls to the web service will fail unless the Silverlight project is hosted in and launched from the same web project that contains the web services.”

What do I need to change to allow me to debug the WCF service?

Upvotes: 1

Views: 1293

Answers (1)

chris.house.00
chris.house.00

Reputation: 3301

It sounds like your Silverlight application and WCF Service application are using two different ASP.Net projects within your solution. To debug them in a single solution they'd need to be in the same ASP.Net website.

Upvotes: 2

Related Questions