Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 是否使用WP 8.0应用程序在WP 8.1上创建AdvertisingManager.advertisingId?_C#_.net_Windows Phone 8_Windows Phone 8.1_System.reflection - Fatal编程技术网

C# 是否使用WP 8.0应用程序在WP 8.1上创建AdvertisingManager.advertisingId?

C# 是否使用WP 8.0应用程序在WP 8.1上创建AdvertisingManager.advertisingId?,c#,.net,windows-phone-8,windows-phone-8.1,system.reflection,C#,.net,Windows Phone 8,Windows Phone 8.1,System.reflection,我有一个WP 8.0应用程序 当它在WP 8.1设备上运行时,我是否有办法(通过反射或其他方式)检索以下值: Windows.System.UserProfile.AdvertisingManager.AdvertisingId; 或者我是否需要制作两个不同的应用程序,一个用于WP 8.0(用于过时的手机),另一个用于WP8.1(用于获取此广告ID)?能否添加一些其他上下文或文档来解释这是如何回答您的问题的?此代码在WP8.0应用程序上编译(问题中的行不是)。当您在WP8.1手机上运行此WP8

我有一个WP 8.0应用程序

当它在WP 8.1设备上运行时,我是否有办法(通过反射或其他方式)检索以下值:

Windows.System.UserProfile.AdvertisingManager.AdvertisingId;

或者我是否需要制作两个不同的应用程序,一个用于WP 8.0(用于过时的手机),另一个用于WP8.1(用于获取此广告ID)?

能否添加一些其他上下文或文档来解释这是如何回答您的问题的?此代码在WP8.0应用程序上编译(问题中的行不是)。当您在WP8.1手机上运行此WP8.0应用程序时,您将获得所需的值。我从微软的Windows中吸收了反射的思想,显然这是微软Windows的大多数新功能的发展方向。
var type = Type.GetType("Windows.System.UserProfile.AdvertisingManager, Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime");
return type != null ? (string) type.GetProperty("AdvertisingId").GetValue(null, null) : "";