I have added a web service reference in my C# metro Style App and it is added successfully.

But when I try to call the async method it tells to use await before the function call.
But when I use await it tells 'await' operator can only be used within an async method.

Can someone please assist what am I missing while adding the webservice.

When I followed the same steps for WPF project it worked smoothly.

*
**GetTravelAdaptorProductsResponse r = ws.GetTravelAdaptorProductsAsync("India", "Pakistan");***

Error 1 Cannot implicitly convert type 'System.Threading.Tasks.Task<TravelAdaptorMetro.MDRWebService.GetTravelAdaptorProductsResponse>' to 'TravelAdaptorMetro.MDRWebService.GetTravelAdaptorProductsResponse' C:\rahul pro\TravelAdaptorMetro\TravelAdaptorMetro\AllProductPage.xaml.cs 47 51 TravelAdaptorMetro

***
GetTravelAdaptorProductsResponse r = await ws.GetTravelAdaptorProductsAsync("India", "Pakistan");***

Error 2 The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'. C:\rahul pro\TravelAdaptorMetro\TravelAdaptorMetro\AllProductPage.xaml.cs 47 50 TravelAdaptorMetro

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.