Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt ActiveX: threw an exception of type 'System.Invalid.CastException'
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 628 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cbries
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved