Qt ActiveX: threw an exception of type 'System.Invalid.CastException'



  • Hello everyone,

    I have created an ActiveX standalone server with Qt's activex support. So far, the activex server has been registered in the registry, the COM interface can be queries, BUT after creating a new activex server class instance a "System.InvalidCastException" rises.

    I like to use the Qt ActiveX component within a C# .Net Application for Windows 7.

    • reference to the manually created interop reference has been added to VisualStudio
    • the using statement has been added
    • the interface and classes are accessible and it seems the class can be instantiated

    The simple testing application is:
    @
    using TcHmiCreatorLib;

    namespace WindowsFormsApplication1
    {
    static class Program
    {
    [STAThread]
    static void Main()
    {
    ITcHmiAxServer tchmi = new TcHmiAxServerClass();
    if (tchmi != null)
    {
    Trace.WriteLine("Server interface ok");
    }
    }
    }
    }
    @

    Outputs:
    @
    ...
    The thread '<Thread Ended>' (0x9d8) has exited with code 0 (0x0).
    The thread '<Thread Ended>' (0x1bc0) has exited with code 0 (0x0).
    Server interface ok
    ...
    @

    But with the Debugger I get the following values:
    @

    • [TcHmiCreatorLib.TcHmiAxServerClass] {TcHmiCreatorLib.TcHmiAxServerClass} TcHmiCreatorLib.TcHmiAxServerClass
    • acceptDrops '((TcHmiCreatorLib.TcHmiAxServerClass)(tchmi)).acceptDrops' threw an exception of type 'System.InvalidCastException' bool {System.InvalidCastException}
    • accessibleDescription '((TcHmiCreatorLib.TcHmiAxServerClass)(tchmi)).accessibleDescription' threw an exception of type 'System.InvalidCastException' string {System.InvalidCastException}
    • accessibleName '((TcHmiCreatorLib.TcHmiAxServerClass)(tchmi)).accessibleName' threw an exception of type 'System.InvalidCastException' string {System.InvalidCastException}
    • autoFillBackground '((TcHmiCreatorLib.TcHmiAxServerClass)(tchmi)).autoFillBackground' threw an exception of type 'System.InvalidCastException' bool {System.InvalidCastException}
    • cursor '((TcHmiCreatorLib.TcHmiAxServerClass)(tchmi)).cursor' threw an exception of type 'System.InvalidCastException' TcHmiCreatorLib.MousePointer {System.InvalidCastException}
    • enabled '((TcHmiCreatorLib.TcHmiAxServerClass)(tchmi)).enabled' threw an exception of type 'System.InvalidCastException' bool {System.InvalidCastException}
    • FocusPolicy '((TcHmiCreatorLib.TcHmiAxServerClass)(tchmi)).FocusPolicy' threw an exception of type 'System.InvalidCastException' TcHmiCreatorLib.FocusPolicy {System.InvalidCastException}
    • font '((TcHmiCreatorLib.TcHmiAxServerClass)(tchmi)).font' threw an exception of type 'System.InvalidCastException' stdole.IFontDisp {System.InvalidCastException}
      ..
      ..
      ..
      etc.
      @

    Any idea how to fix this?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.