c# - How to support Windows 8 & 8.1 Geolocation API -


i've added geolocation support program have problem i'm not sure how handle. i'm using vs 2012.

i've added dll solution makes of geolocation calls. set version of windows supported 8.1 in .csproj file. dll project uses .net 4.5, while rest of projects in solution use .net 4.0.

i've got following code in method retrieves position:

protected override void initialize() {     // initialization code here      parsegeoposition();  // exception thrown on line }  private void parsegeopositin() {      // . . .      bool done = false;     while ( !done )         try {             if ( usecoordinate ) {                 newposition.position.latitude  = positionrecord.coordinate.latitude;                 newposition.position.longitude = positionrecord.coordinate.longitude;             } else {                 newposition.position.latitude  = positionrecord.coordinate.point.position.latitude;                 newposition.position.longitude = positionrecord.coordinate.point.position.longitude;             }             done = true;         } catch ( missingmethodexception ) {             if ( !usecoordinate ) {                 throw new notsupportedexception( "this machine not support windows geolocation api." );             }             usecoordinate = false;         }     // . . . } 

the usecoordinate flag starts out true. code supposed switch using point property (by setting usecoordinate false if coordinate property not supported.

the code runs fine on windows 8.1 development machine. but, when install on windows 8.0 machine, missingmethodexception being thrown on line calls method has code in it. it's though try isn't there. exception thrown reads:

system.missingmethodexception: method not found: 'windows.devices.geolocation.geopoint windows.devices.geolocation.geocoordinate.get_point()'.

obviously approach flawed. i'd prefer not @ windows version number manager not want me to. what's right way code this

the exception happening, when method being compiled jiter - either need use 8.0 compatible geo-location api calls (geolocator , friends), or guard calls methods use 8.1 specific instructions appropriate try ... catch blocks.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -