Hi all (and Mark).
As I have posted a few times the last few weeks about my GPS application, I have got to the point of adding the GPS stuff in. I am using the Windows Mobile 6 SDk and used the Microsoft.WindowsMobile.Samples.Location project code for my project.
Now, the problem is I am getting an error, sometimes straight away (once the GPS is initialised) or during the use of it.
I get an "unexpected" error occuring and the only other information is ArgumentException Parameter Name chars.
Here are the full details of the Exception:
ArgumentException
ArgumentException
Parameter name: chars
at System.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, UTF8Encoder encoder)
at System.Text.UTF8Encoding.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, UTF8Encoder encoder)
at System.Text.UTF8Encoding.UTF8Encoder.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, Boolean flush)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at Microsoft.WindowsMobile.Samples.Location.Gps.GetPo sition(TimeSpan maxAge)
at Microsoft.WindowsMobile.Samples.Location.Gps.GetPo sition()
at Microsoft.WindowsMobile.Samples.Location.Gps.WaitF orGpsEvents()
Now, I know it isnt coming from my software as when I am debugging it (not emulator but connected the the WM6 device) it states the symbols cannot be loaded for debug. I am presuming it is something in the included DLL (the Microsoft.WindowsMobile.Samples.Location.dll) from theWindows Mobile 6 SDK.
When I am debugging, I can get the Gps.cs SDK file to show itself (different reason) and it states the DLL it is using compared to the cs file is different. I havent recompiled anything, but wondering if the DLL I am using is NOT the correct one and this error is fixed in a different DLL (Just thinking out loud here and trying to supply all information).
I have seen someone ask the same question in MSDN forums, but he was ignored.
Has anyone (Mark?) had the same error when using the SDK's DLL?
What is strange as it seems the Location Sample works fine. However, I am using the exact same code, in a class, within my application.
Please... Any ideas?
Thanks,
Rob
11 4522
You can build and run the sample without any problems? You should compare your project files and see if you have some missing settings that the sample project does not.
Hi Redson,
Thanks for the reply, but I have exactly the same code as per the example. It is very simple code as most of the work is done by the DLL. (I have double checked).
I have also created a new simple app, with the code from the example and I get the same error. The app doesnt display the values as per the sample (thats the only difference). I just load up a variable with the information, then display it when I push a button.
I actually found all the source in the SDK folder that created the DLL, so I have recompiled the DLL and will test with this DLL.
Rob
Right, if it's simple and most of the work is done in the dll but you are having problems. Then the problem is likely in your project setup not your code.
But, the DLL seems to be throwing the error in the routine when it is getting the information after the GPS event has fired. Would you say that is true (going by the error information provided)???
The app doesnt need to do anything other than call the gps.Open command, so I cant understand why anything in the app could cause this issue.
I will go over my stuff again.
Thanks,
Rob
Ok, I think I might have found the issue, but as the error occurs randomly (usually within the first 5 minutes of operation), I have my fingers crossed as it has been running for a hour so far.
I found another sample using the same code. The original code (which I thought was from the SDK example, wasnt), had one of the routines (gps_LocationChanged) as public void. Thi other sample I found buried in the SDK folders had the same routine as protected void. I change my definition to protected and as mentioned, it didnt fall over within the first 5-10 minutes.
Here's hoping this was the issue.
Oh strange, sometimes you run into those errors that just don't make any sense. Well I'm glad you found it.
Yep, your right... I still cant see why they would make that much a difference, but I am no expert on this.
It seem to go OK with the test so far...I am not trusting it just yet until I have used the app a fair few more times, but so far, so good.
Thanks,
Rob
Ok.. spoke too soon..
Tried it twice today and it failed the second time.
Tried the MS sample and it fails (just takes longer).
So, it isnt my code after all that (by the looks of it)...
Any ideas to check?
Thanks,
Rob
Time to post your code....
Use [code] tags, or make a zip file, or use a paste bin.
Redson,
Thanks for trying to help, and it would be easy if your saw the code, but are you following that ALL the code, and where the error is occuring is in the MS SDK Sample Code.
All I do is: -
using Microsoft.WindowsMobile.Samples.Location;
-
-
.....
-
-
Gps mygps = new Gps();
-
-
I then setup the handlers and open the GPS as per the MS example -
-
mygps.DeviceStateChanged += new DeviceStateChangedEventHandler(gps_DeviceStateChanged);
-
mygpsLocationChanged += new LocationChangedEventHandler(gps_LocationChanged);
-
mygps.Open();
-
The handlers are coded as such (I update some variables in these routines) -
-
public void gps_DeviceStateChanged(object sender, DeviceStateChangedEventArgs args)
-
{
-
GpsDeviceState device = args.DeviceState;
-
-
_GPSStatus = device.DeviceState.ToString();
-
_GPSDeviceName = device.FriendlyName;
-
_GPSDeviceState = device.DeviceState.ToString();
-
_GPSServiceState = device.ServiceState.ToString();
-
}
-
-
public void gps_LocationChanged(object sender, LocationChangedEventArgs args)
-
{
-
GpsPosition position = args.Position;
-
-
if (position.LatitudeValid)
-
_CurrentLatitude = position.Latitude;
-
if (position.LongitudeValid)
-
_CurrentLongitude = position.Longitude;
-
if (position.HeadingValid)
-
_CurrentHeading = position.Heading;
-
if (position.SatellitesInViewCountValid)
-
_Satellites = position.SatellitesInViewCount;
-
-
} // End gps_LocationChanged
-
-
Thats all I do.
Regards,
Rob
I have experienced the SDK device error (null exception) that happens at randomn intervals. I think this may be when no satellites are visible. In GetSatellitesInSolution() it does a for loop which references inViewSatellites.Length but if inViewSatellites is null then this would go bang. So I have wrapped this in a null check and so far so good.
I saw this in the code on http://gpstracka.codeplex.com/
Hope this helps...
Code
====
public Satellite[] GetSatellitesInSolution()
{
Satellite[] inViewSatellites = GetSatellitesInView();
ArrayList list = new ArrayList();
for (int index = 0; index < dwSatelliteCount; index++)
{
Satellite found = null;
//check whether any satellites were inView
if (inViewSatellites != null)
{
for (int viewIndex = 0; viewIndex < inViewSatellites.Length && found == null; viewIndex++)
{
if (rgdwSatellitesUsedPRNs[index] == inViewSatellites[viewIndex].Id)
{
found = inViewSatellites[viewIndex];
list.Add(found);
}
}
}
}
return (Satellite[])list.ToArray(typeof(Satellite));
}
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tarren |
last post by:
Hi:
The problem I am having is when I validate an xml file to a schema, it is
erroring out every element. I think this has something to do with me
defining/referencing the namespaces. I have...
|
by: Nick White [MSFT] |
last post by:
Hello fellow Microsoft Windows Mobile and Embedded enthusiasts:
I invite you to peruse the list below of upcoming technical chats and
Webcasts offered by the Windows Mobile and Embedded Devices...
|
by: Sacha Korell |
last post by:
First of all, sorry for cross-posting, but this newsgroup is much busier
than "aspnet.mobile".
I'm trying to create a portal page that redirects depending on the device
that is connecting.
...
|
by: Jarod_24 |
last post by:
I just downloaded a activex control that was written in C# and tried to view
it on my PDA's Internet Explorer.
At my regular PC it displayed just fine, but nothing showed up on the pda.
Do...
|
by: sakurasyi |
last post by:
hi everyone...
i have some questions about windows ce. Can anybody tell me, what are the differences between widows ce, windows mobile and posket pc?
I have read about windows ce from some...
|
by: Ilkka Maatta |
last post by:
I test Opera 8.60 for Windows Mobile, Pocket PC becouse i need JAVA script
and sound in my www-page.
My mobile PC is Ipaq 3850 / Pocket PC 2003 and browser is Opera 8.60 for
Windows Mobile,...
|
by: Sharky Ward |
last post by:
We have a C# windows mobile form application designed for PockedtPC 2003 developed in VS2003.NET with .NET 1.0/1.1.
Some of the mobile devices have been replaced with Windows Mobile 5.0.
As a...
|
by: =?Utf-8?B?V29vZGdub21l?= |
last post by:
Hi,
I have use the following code to transmit a file back to the browser that
worked fine on a HTC_TTyN device running windows mobile 5.0. The code
executes in the onclick event of a mobilelist...
|
by: JayaseelanVaiyapuri |
last post by:
Hi all,
I have done with Symbian and Blackberry for retrieving Mobile Country Code(MCC)
from my mobile using my app..
Now i want to know how to get the MCC for Windows Mobile using Win32...
|
by: bolineni |
last post by:
Hi
i developed a windows mobile application in .net cf3.5.
when i am trying to deploy this application on palm os device by using "Palm One quick install", it is giving 'Incompatible HandHeld...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |