DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2007
    Posts
    2

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

    Hi,

    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.

    Kalyan

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

    The ComInterface is Method(LPDISPATCH x).

    In C# we use
    cONTROL.METHOD(X);
    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

Bookmarks

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links