If you've asked a question, please remember to mark the best answer as 'accepted' by clicking the check mark next to your preferred answer. It looks like the checkmark to the left, and is right under the vote section. You'll gain some reputation and it helps us surface the best content.
2

I have an ASCOM focuser that is failing Conform 3.0.0.17 early binding check, all other Conform tests pass.

Message seen: AccessChecks ERROR Error creating driver using early binding to IFocuser interface: Unable to cast COM object of type 'System.__ComObject' to interface type 'ASCOM.Interface.IFocuser'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C2E3FE9C-01CD-440C-B8E3-C56EE9E4EDBC}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

I see other drivers also fail same check (Meade, MeadeEx, OptecTCF, RoboFocusServer, JMISmartFocus, AstroPhysics) and passes for Simulator, LittleFootClassic)

What is IFocuser?

Clues on getting past this?

Gene

flag
Master Interfaces and Bindings reference: "It is now a goal of ASCOM to have drivers not only support late binding, but also expose a generic or master interface for the driver type to permit interface-based early-binding. This is possible in most languages and development systems including VB6 (the technique was not evident until recently). " Where can I find more info about the technique for VB6 based drivers? Thanks! Gene – lynol1000 Mar 8 at 20:30
If you want to add more information to your question you can do so by clicking the "Edit' link-button just below your original question. – Jordan S Mar 8 at 22:18

2 Answers

1

The solution with minimal dev environment (straight up VB6 standalone) and code changes was found in Focuser.cls of POTH v5.0.1.

Make sure "ASCOM Master Interface for .NET and COM" is checked in the project References

And then add after:

Option Explicit

Use:

Option Explicit

Implements IFocuser

And then for each Property and Method define IFocuser_* similar to:

Private Property Get IFocuser_Temperature() As Double

IFocuser_Temperature = Temperature

End Property

I did not need to change the initial registration method.

Thanks Jordan for your insights!

Gene

link|flag
Nice work! You're welcome. – Jordan S Mar 10 at 12:17
0

I am not sure why you are having the early binding issue. If you build your driver from the driver templates they are already setup do to the early and late binding properly so this shouldn't be a problem. If you changed any of the original code that was created via the template try undoing those changes.

IFocuser is an interface that specifies the standard, mandatory methods and properties of every ASCOM focuser driver. Do a google search or msdn search for more info on .NET interfaces.

One guess as to the reason all of those drivers are failing Conform: Maybe they were written back before the release of ASCOM Platform 5.5. The current version of Conform checks that drivers conform with the current version of the Platform. There were some changes made to the way drivers are registered in the new platform update. It is up to the device manufacturers to make sure that their drivers are up to date and work properly with the most recent version of the Platform. Hence, there is a newer version of the OptecTCF driver that is available for download on their website that does pass conform!

If you are trying to update an older driver it might be helpful to build a new driver project from the current template and look at the driver.cs. Compare the way that the new one does the registration to the way yours does the registration and try to make them alike. The old drivers used a component called Helper or Helper2 to do registration and now it has been moved to a new component called Utilities. You will need to download the utilities class and add a reference to it in your project.

You should end up with something like this...

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

using ASCOM;
using ASCOM.Utilities;
using ASCOM.Interface;


namespace ASCOM.OptecTCF_S
{
//
// Your driver's ID is ASCOM.OptecTCF_S.Focuser
//
// The Guid attribute sets the CLSID for ASCOM.OptecTCF_S.Focuser
// The ClassInterface/None addribute prevents an empty interface called
// _Focuser from being created and used as the [default] interface
//
[Guid("4103b899-c887-4f8b-a085-8be9e1ebc183")]
[ClassInterface(ClassInterfaceType.None)]
public class Focuser : IFocuser
{
    //
    // Driver ID and descriptive string that shows in the Chooser
    //
    internal static string s_csDriverID = "ASCOM.OptecTCF_S.Focuser";
    private static string s_csDriverDescription = "Optec TCF-S Focuser";    //Displayed in Chooser

    //
    // Constructor - Must be public for COM registration!
    //
    public Focuser()
    {
        // TODO Implement your additional construction here
    }

    #region ASCOM Registration
    //
    // Register or unregister driver for ASCOM. This is harmless if already
    // registered or unregistered. 
    //
    private static void RegUnregASCOM(bool bRegister)
    {
        //Helper.Profile P = new Helper.Profile();
        Utilities.Profile P = new Utilities.Profile();
        P.DeviceType = "Focuser";                   
        if (bRegister)
            P.Register(s_csDriverID, s_csDriverDescription);
        else
            P.Unregister(s_csDriverID);
        try                                     
        {
            Marshal.ReleaseComObject(P);
        }
        catch (Exception) { }
        P = null;
    }

    [ComRegisterFunction]
    public static void RegisterASCOM(Type t)
    {
        RegUnregASCOM(true);
    }

    [ComUnregisterFunction]
    public static void UnregisterASCOM(Type t)
    {
        RegUnregASCOM(false);
    }
    #endregion
link|flag
This driver is based upon something way before ASCOM 5.5, more like 4.1 and not built from any templates. Seems only early bindings are an issue as of now and yes, I am trying to have my driver adhere to current standards. – lynol1000 Mar 8 at 23:35
Ok, now that does give me a clue! I am written in VB6 using VB6 standalone without VisualStudio. Current init registration: Public Const idT As String = "XYZ.Focuser" Private Const DESCT As String = "XYZ Focuser" Public g_ProfileT As DriverHelper.Profile g_ProfileT.Register idT, DESCT I am choosing as highest priority reference "ASCOM Master Interfaces for .NET and COM (V1.0)". – lynol1000 Mar 9 at 14:24
Looking through the POTH source for 5.0.1 version seems to provide VB6 and IFocuser information. – lynol1000 Mar 9 at 15:18
You could download one of the Express versions of Visual Studio for either VB or C#.NET! The templates do support the Express versions and they are nearly as full featured as the full version! – Jordan S Mar 9 at 17:00

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.