0

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

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by pritaeas
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.