DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sat, 11 Aug 2007 13:52:14 -0500,    posted on: microsoft.public.dotnet.framework.interop        back       

Thread Index
  1    Chris Yager lid
          2    Chris Yager lid
          3    Mattias Sjgren
          4    Chris Yager lid
          5    Johannes Passing
          6    Chris Yager lid


Interop from a timer event   
I have a service that accesses a VB6 COM component on a timer event.  On 
64-bit windows (running in 32-bit "mode") the process fails if it is run in 
a secondary thread but works fine when run on the main thread.  This 
behavior cannot be re-produced in 32-bit environment.

Any help would be greatly appreciated.

The error is:

System.InvalidCastException: Unable to cast COM object of type 'blah.type' 
to interface type 'blah.interfacetype'. This operation failed because the 
QueryInterface call on the COM component for the interface with IID 
'{[guid....]]}' failed due to the following error: Error loading type 
library/DLL. (Exception frm HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

The exact code from the same components runs fine in 64-bit environment 
(again running in 32-bit mode) if it is not run on a secondary thread.

I'm not using a primary interop assembly and nothing is running from the GAC 
except framework stuff.

thanks,
-chris
Date:Sat, 11 Aug 2007 13:52:14 -0500   Author:  

Re: Interop from a timer event   
I should mention:  All code is C# targeting x86 cpu using framework 2.0

i have a "fairly" simple example that demonstrates the problem.

-chris

"Chris Yager" <chris.yager@gldsolutions.com.invalid> wrote in message 
news:Oy5gujE3HHA.4184@TK2MSFTNGP06.phx.gbl...

>I have a service that accesses a VB6 COM component on a timer event.  On 
>64-bit windows (running in 32-bit "mode") the process fails if it is run in 
>a secondary thread but works fine when run on the main thread.  This 
>behavior cannot be re-produced in 32-bit environment.
>
> Any help would be greatly appreciated.
>
> The error is:
>
> System.InvalidCastException: Unable to cast COM object of type 'blah.type' 
> to interface type 'blah.interfacetype'. This operation failed because the 
> QueryInterface call on the COM component for the interface with IID 
> '{[guid....]]}' failed due to the following error: Error loading type 
> library/DLL. (Exception frm HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
>
> The exact code from the same components runs fine in 64-bit environment 
> (again running in 32-bit mode) if it is not run on a secondary thread.
>
> I'm not using a primary interop assembly and nothing is running from the 
> GAC except framework stuff.
>
> thanks,
> -chris
> 
Date:Sat, 11 Aug 2007 13:59:34 -0500   Author:  

Re: Interop from a timer event   

>I have a service that accesses a VB6 COM component on a timer event.  On 
>64-bit windows (running in 32-bit "mode") the process fails if it is run in 
>a secondary thread but works fine when run on the main thread.  This 
>behavior cannot be re-produced in 32-bit environment.
>
>Any help would be greatly appreciated.



I'm guessing the thread has the wrong ApartmentState.


Mattias

-- 
Mattias Sjgren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Date:Mon, 13 Aug 2007 00:20:04 +0200   Author:  

Re: Interop from a timer event   
I'd considered that but it behaves well in 32-bit windows.

thanks for the response,
-chris

"Mattias Sjgren"  wrote in message 
news:e4p2A8S3HHA.1184@TK2MSFTNGP04.phx.gbl...

>
>>I have a service that accesses a VB6 COM component on a timer event.  On
>>64-bit windows (running in 32-bit "mode") the process fails if it is run 
>>in
>>a secondary thread but works fine when run on the main thread.  This
>>behavior cannot be re-produced in 32-bit environment.
>>
>>Any help would be greatly appreciated.
>
>
> I'm guessing the thread has the wrong ApartmentState.
>
>
> Mattias
>
> -- 
> Mattias Sjgren [C# MVP]  mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup. 
Date:Sun, 12 Aug 2007 18:35:55 -0500   Author:  

Re: Interop from a timer event   
Hi Chris,

the error message indicates that the typelib cannot be loaded - can you 
load it manually using LoadRegTypeLib (on 64-bit windows) or do you get 
the same error?

--Johannes

Chris Yager wrote:

> I'd considered that but it behaves well in 32-bit windows.
> 
> thanks for the response,
> -chris
> 
> "Mattias Sjgren"  wrote in message 
> news:e4p2A8S3HHA.1184@TK2MSFTNGP04.phx.gbl...
>>> I have a service that accesses a VB6 COM component on a timer event.  On
>>> 64-bit windows (running in 32-bit "mode") the process fails if it is run 
>>> in
>>> a secondary thread but works fine when run on the main thread.  This
>>> behavior cannot be re-produced in 32-bit environment.
>>>
>>> Any help would be greatly appreciated.
>>
>> I'm guessing the thread has the wrong ApartmentState.
>>
>>
>> Mattias
>>
>> -- 
>> Mattias Sjgren [C# MVP]  mattias @ mvps.org
>> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
>> Please reply only to the newsgroup. 
> 
> 



-- 
Johannes Passing - http://int3.de/
Date:Mon, 13 Aug 2007 17:47:08 +0200   Author:  

Re: Interop from a timer event   
Thanks to all for the help.
The problem was the apartment state.

I spawned an additional thread off the timer's thread and set the apartment 
state to "STA" and everything works as expected.

Thanks again,
-chris

"Mattias Sjgren"  wrote in message 
news:e4p2A8S3HHA.1184@TK2MSFTNGP04.phx.gbl...

>
>>I have a service that accesses a VB6 COM component on a timer event.  On
>>64-bit windows (running in 32-bit "mode") the process fails if it is run 
>>in
>>a secondary thread but works fine when run on the main thread.  This
>>behavior cannot be re-produced in 32-bit environment.
>>
>>Any help would be greatly appreciated.
>
>
> I'm guessing the thread has the wrong ApartmentState.
>
>
> Mattias
>
> -- 
> Mattias Sjgren [C# MVP]  mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup. 
Date:Wed, 15 Aug 2007 08:40:57 -0500   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us