Hệ thống thông tinApp không sụp đổ khi gỡ lỗi, nhưng Có Khi Chạy thường
- Windows 10 kỹ thuật trước (xây dựng 9926)
- Visual Studio 2013 Cộng đồng
Cố gắng để gỡ lỗi trên:- [AT & T] Lumia 635 (Bản xem trước kỹ thuật cho Windows 10 cho điện thoại được xây dựng 9941 w/Lumia Cyan)
- [AT & T] Lumia 1520 (Windows Phone 8.1 với Lumia Denim và PFD)
- [Unlocked] BLU Win Jr (Windows Phone 8.1 với PFD)
- [Verizon] Lumia Icon (Windows Phone 8.1 với Lumia Denim và PFD)
tôi cố gắng để có được dịch vụ định vị làm việc trong ứng dụng của tôi. Trước đây, tôi đã có Visual Studio ném lỗi. Đó là một số ArgumentException
với thông báo "Use of undefined keyword value 1 for event TaskScheduled in async
". Googling không bật lên bất kỳ giải pháp nào.
Đây là mã:
Geolocator Locator = new Geolocator();
Geoposition Position = await Locator.GetGeopositionAsync();
Geocoordinate Coordinate = Position.Coordinate;
Khi tôi có thể nhận được lỗi được ném ra, các ngoại lệ được ném trên dòng thứ 2 hoặc thứ 3 trong ví dụ trên. tôi đơn giản hóa mã gốc để thử và sửa chữa nó, nhưng đây là bản gốc:
Geolocator Locator = new Geolocator();
Geocoordinate Coordinate = (await Locator.GetGeopositionAsync()).Position.Coordinate;
Toàn bộ ứng dụng hoạt động khi gỡ lỗi, nhưng bị treo gần như ngay lập tức bằng cách khác.
Đây là dự án Windows 8.1 Universal, tập trung vào dự án điện thoại.
Cảm ơn trước
EDIT: Theo yêu cầu, ở đây có đầy đủ các phương pháp:
private static bool CheckConnection()
{
ConnectionProfile connections = NetworkInformation.GetInternetConnectionProfile();
bool internet = connections != null && connections.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess;
return internet;
}
public static async Task<double> GetTemperature(bool Force)
{
if (CheckConnection() || Force)
{
Geolocator Locator = new Geolocator();
await Task.Yield(); //Error occurs here
Geoposition Position = await Locator.GetGeopositionAsync();
Geocoordinate Coordinate = Position.Coordinate;
HttpClient Client = new HttpClient();
double Temperature;
Uri u = new Uri(string.Format("http://api.worldweatheronline.com/free/v1/weather.ashx?q={0},{1}&format=xml&num_of_days=1&date=today&cc=yes&key={2}",
Coordinate.Point.Position.Latitude,
Coordinate.Point.Position.Longitude,
"API KEY"),
UriKind.Absolute);
string Raw = await Client.GetStringAsync(u);
XElement main = XElement.Parse(Raw), current_condition, temp_c;
current_condition = main.Element("current_condition");
temp_c = current_condition.Element("temp_C");
Temperature = Convert.ToDouble(temp_c.Value);
switch (Memory.TempUnit)
{
case 0:
Temperature = Convertions.Temperature.CelsiusToFahrenheit(Temperature);
break;
case 2:
Temperature = Convertions.Temperature.CelsiusToKelvin(Temperature);
break;
}
return Temperature;
}
else
{
throw new InvalidOperationException("Cannot connect to the weather server.");
}
}
EDIT 2: Tôi đã asked for help on Twitter, và received a reply hỏi cho một dự án repro. Tôi đã tạo lại phần chính của ứng dụng gốc, nhưng tôi không thể nhận được lỗi. Tuy nhiên, lỗi có thể xảy ra cho bạn so here's the project.
EDIT 3: Nếu nó giúp ở tất cả, đây là các chi tiết ngoại lệ:
System.ArgumentException occurred
_HResult=-2147024809
_message=Use of undefined keyword value 1 for event TaskScheduled.
HResult=-2147024809
IsTransient=false
Message=Use of undefined keyword value 1 for event TaskScheduled.
Source=mscorlib
StackTrace:
at System.Diagnostics.Tracing.ManifestBuilder.GetKeywords(UInt64 keywords, String eventName)
InnerException:
Bạn không đơn độc, hãy kiểm tra [this] (https://social.msdn.microsoft. com/Diễn đàn/windowsapps/en-US/3e505e04-7f30-4313-aa47-275eaef333dd/systemargumentexception-use-of-undefined-keyword-value-1-for-event-taskcheduled-in-async? forum = wpdevelop) và [ này] (http://stackoverflow.com/questions/24747885/argumentexception-use-of-undefined-keyword-value-1-for-event-taskscheduled-in). Để giải quyết vấn đề này, hãy xem liệu điều này có giúp ích không: 'Vị trí địa lý = chờ đợi Task.Run (() => Locator.GetGeopositionAsync());' – Noseratio
@Noseratio Tôi đã thử mọi thứ tôi có thể trong hai chủ đề bạn đã liên kết. Ngoài ra, tôi đã thử cách giải quyết mà bạn đã đưa ra. Nó vẫn hoạt động hoàn hảo trong khi gỡ lỗi, nhưng nó vẫn treo trong khi không gỡ lỗi. Cảm ơn bạn đã trả lời –
Rõ ràng, đó là lỗi WP/WRT, tôi báo cáo tại http://connect.microsoft.com. BTW, hãy thử điều này: 'chờ đợi Task.Yeild(); Geocoordinate Coordinate = (đang chờ Locator.GetGeopositionAsync()) Position.Coordinate; 'Nó có bị sập sau' Task.Yeild() 'hay sau khi' đang chờ Locator.GetGeopositionAsync() '? – Noseratio