DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Feb 2007

    Bad Variable exception, when using an ActiveX on WinForm as a seperate Thread.


    I have typical problem which i am trying for past 4 days. I am newbie to .NET world.
    I have a ocx component which i have to use in C#. So i hosted it on a winform and can use it without problems.

    How ever if i make this Winform as a seperate thread and use the same interface which is worked in above case(Winform as not a seperate thread) it is giving BAD VARIABLE TYPE exception.

    I have used BeginInvoke and delegate method in MainThread to start execution of the member function in WinForm thread. And in Debug->Threads window i can see thread switch happened without any problems. How ever when we call the interface it throws the exception.

    I tried to debug the ActiveX code. It fails in ForwardCalltoInvoke... method. I dont understand why it is ailing in second case, as i pass same variable type in both the cases.

    Any help would do great for me.


  2. #2
    Join Date
    Feb 2007
    Hi Some More info on the problem.

    The ComInterface is Method(LPDISPATCH x).

    In C# we use
    The Object x is actually creadted from some other vc++DLL SO IT IS ALSO UNMANAGED TYPE.
    sO WHEN IT IS CREATED .net represents it as System.__ComObject and while using the above method it is unable to convert from System.__ComObject to LPDISPATCH.

    I tried marshal.getiDistpachPointer for explicit marshalling, but it doesnt work.

    But if everything is executed in MainThread then it is working fine.
    Any clues?

Similar Threads

  1. Replies: 0
    Last Post: 12-09-2001, 11:45 AM
  2. Replies: 0
    Last Post: 05-10-2001, 05:33 AM
  3. Thread problem with static variable - pls help
    By Lim Wing Hoe in forum Java
    Replies: 0
    Last Post: 12-29-2000, 10:31 AM
  4. bad attribute exception
    By John in forum Java
    Replies: 0
    Last Post: 12-07-2000, 01:57 AM
  5. Java Thread
    By Kevin Chien in forum Java
    Replies: 3
    Last Post: 09-12-2000, 05:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.