I've hit a problem trying to enumerate the TrackingRates for my driver. The driver uses the LocalServer template as-is. Ascom Conform gets a similar error when trying to reference the tracking rates. Here's the Conform error message:
18:27:48.093 Tracking Read OK True
18:27:48.296 Tracking Write OK False
18:27:48.562 TrackingRates ERROR .NET - Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Conform.TelescopeTester.CheckProperties() in C:\Documents and Settings\Peter\My Documents\Visual Studio 2008\Projects\Conform\Conform\Devices\TelescopeTester.vb:line 1845
In my test client, the enumeration seems to fail when using the 'foreach' mechanism:
ITrackingRates oTrackingRates;
IAxisRates oAxisRates;
sName = ASCOM.DriverAccess.Telescope.Choose("ASCOM.bwAstroPhysics.Telescope");
if (sName.Length > 0)
{
f_oScope = new ASCOM.DriverAccess.Telescope(sName);
f_oScope.Connected = true;
// AxisRate enumeration works correctly...
oAxisRates = f_oScope.AxisRates (ASCOM.Interface.TelescopeAxes.axisPrimary);
foreach (IRate oRate in oAxisRates)
MessageBox.Show((oRate.Maximum).ToString());
oTrackingRates = f_oScope.TrackingRates;
// This form of iteration on TrackingRates works correctly...
for (int iInx = 1; iInx <= oTrackingRates.Count; iInx++)
MessageBox.Show(oTrackingRates[iInx].ToString());
// This form fails because eRate is null
foreach (DriveRates eRate in oTrackingRates)
MessageBox.Show(eRate.ToString());
This seems like a bonehead problem to have, but I haven't figured it out.
3/9/10 Update: Per Bob's suggestion, I tested the same code in the DLL version of the driver, and the enumeration works fine. So the 'GetEnumerator' function in the out-of-proc server implementation seems to be failing for some reason. I was careful about this - the test app is literally the same one, using either the DLL or exe versions of the driver. I agree, there's nothing in LocalServer.cs that has anything to do with this, but the behavior of the driver code changes from one form of implementation to the other. Any other ideas?
