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.
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.
Last Post: 12-09-2001, 11:45 AM
By Bui Huy Kien in forum Enterprise
Last Post: 05-10-2001, 05:33 AM
By Lim Wing Hoe in forum Java
Last Post: 12-29-2000, 10:31 AM
Last Post: 12-07-2000, 01:57 AM
By Kevin Chien in forum Java
Last Post: 09-12-2000, 05:17 PM
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