Ned Rise

I¡¯m new to pocketpc development with Visual Studio and just learning from the examples shipping with Windows Pocket PC SDK. I¡¯m specially interested in devloping GPS aplications so I¡¯m quite frustrated by getting an DivideByZeroException running the GPS example (http://msdn.microsoft.com/library/default.asp url=/library/en-us/mobilesdk5/html/mogrfGpsSample.asp). The exact error which shows up:

GpsSample.exe
DivideByZeroException

Application::Run+0xf
Form1::Main+0xa

I can¡¯t find any divisions in this example and would appriciate any help to figure out which part of the code throws this exception. I¡¯m running Windows Mobile 5.0 on a Eten X 500 pocket PC (http://www.etencorp.com/products/Communication/X500.php) and cgacutil.exe shows me that I¡¯m running Compact Framework 1&2 [2.0.5238.0, 1.0.4292.2].



Re: .NET Compact Framework DivideByZeroException running GPS example code

Ilya Tumanov

Step through the code with debugger and find the line in which that happens. Then analyze this line and fix the issue.

And you¡¯re running on NETCF V1, by the way.






Re: .NET Compact Framework DivideByZeroException running GPS example code

Ned Rise

Thanks for your hint but ActiveSync tells me that I have Microsoft .NET CF 2.0 installed on my device so I don¡¯t know whom to trust Could I manually install NETCFv2.wm.armv4i.cab file on my device and than executing it Where do I have to put it - in the windows folder





Re: .NET Compact Framework DivideByZeroException running GPS example code

Ned Rise

 Ilya Tumanov wrote:

Step through the code with debugger and find the line in which that happens. Then analyze this line and fix the issue.

finally I learned to use the Visual Studio debugger and found out that the line

return val * (absDegrees / degrees);

in class DegreesMinutesSeconds.cs produced the DivideByZeroException when variable degrees is 0 so I put an if there to handle this case.

 Ilya Tumanov wrote:

And you¡¯re running on NETCF V1, by the way.

How can I find out the version of the NETCF I¡¯m running Which message should cgacutil.exe show Doesn¡¯t the shown version [2.0.5238.0, 1.0.4292.2] mean that I¡¯m running both versions Thanks for your help for a bloody beginner ...





Re: .NET Compact Framework DivideByZeroException running GPS example code

Ilya Tumanov

Yes, it's very easy. Just hit F5, it breaks on exception, you fix it - that's it.

This message means you have both versions installed. Your application, however, is running only on one of them. It's like hawing couple cars in the garage - you have both but you only can drive one at any given moment. From the message you've posted I can see it's V1, so your project must be V1 and you have no configuration file to promote it to V2.

If needed you can see runtime version by checking System.Environment.Version.






Re: .NET Compact Framework DivideByZeroException running GPS example code

Ned Rise

Ilya Tumanov wrote:

Yes, it's very easy. Just hit F5, it breaks on exception, you fix it - that's it.

done! thanks!

Ilya Tumanov wrote:

This message means you have both versions installed. Your application, however, is running only on one of them. It's like hawing couple cars in the garage - you have both but you only can drive one at any given moment. From the message you've posted I can see it's V1, so your project must be V1 and you have no configuration file to promote it to V2.

If needed you can see runtime version by checking System.Environment.Version.

so how can I force my application to run on V2 using System.Environment.Version shows me that you are right and I¡¯m running on V1.





Re: .NET Compact Framework DivideByZeroException running GPS example code

Ilya Tumanov

The best way to go would be to compile it for V2. There's an option to upgrade the project to V2, just look through the menus.






Re: .NET Compact Framework DivideByZeroException running GPS example code

Ned Rise

project -> upgrade project -> broke the Microsoft.WindowsMobile.Samples.Location example: "Metadata file 'd:\Visual Studio 2005\Projects\GpsTestv2\bin\Debug\Microsoft.WindowsMobile.Samples.Location.dll' could not be opened -- 'Version 2.0 is not a compatible version.'"

seems not to be compatible with V2. any idea how to migrate it toV2





Re: .NET Compact Framework DivideByZeroException running GPS example code

Ilya Tumanov

It looks like you have multiple project and one ore more of them remains V1 and could not use V2 DLL. You need to upgrade all of them to V2. If for some reason that failed create fresh V2 project and add files from original project to it.






Re: .NET Compact Framework DivideByZeroException running GPS example code

OscarPeli

It seems to me that the degrees variable is set in a wrong way. I used the Microsoft.WindowsMobile.Samples.Location library to develop a sample application about tracking and I had to modify the code in the following way:

public double ToDecimalDegrees()

{

double retVal;

retVal = minutes + seconds / 60;

return retVal;

//int absDegrees = Math.Abs(degrees);

//double val = (double)absDegrees + ((double)minutes / 60.0) + ((double)seconds / 3600.0);

//return val * (absDegrees / degrees);

}

once recompiled and used in my solution, the library works well.





Re: .NET Compact Framework DivideByZeroException running GPS example code

Daniel K

I ran into the same issues. Here's an explanation: http://blogs.msdn.com/cenet/archive/2006/02/10/529744.aspx