Scansys

I created an application in which I use a COM component (vb6 dll) inside a BackgroundWorker. On the development pc it's working fine, but when I deploy the application it doesn't work.

Error message: Unable to cast COM object of type 'AbbyyComponent.AbbyyClass' to interface type 'AbbyyComponent._Abbyy'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{3D1148F7-B8E7-4DA1-83B3-66A8A5A14042}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
Error source: Interop.AbbyyComponent
Error stack trace: at AbbyyComponent.AbbyyClass.LoadFREngine(String& dllPath)
at ScanSys.ImageCapture.ICCommon.AbbyyEngine.get_Instance() in C:\Projects\_ImageCapture4\ImageCapture4\ICCommon\Help\AbbyyEngine.cs:line 35

So what I did, I created a simple form with 2 buttons. The first button uses the COM component inside a backgroundworker. The second button uses the COM component on the main thread. Button 1 fails, and button 2 works (after deployment).

What I did next, I changed the test application and in the DoWork event I went back to the main thread using a delegate and ISynchronizeInvoke. And now it works on the deployment pc.

But the question remains. Why is it working on my development pc and not after I deployed it to any other pc


Re: Visual C# General Use VB6 COM component in backgroundworker

Peter Ritchie

Have you registered the COM object on the computer where you've deployed




Re: Visual C# General Use VB6 COM component in backgroundworker

Scansys

Yes I did. The component is working fine when deployed and when I don't use the backgroundworker. But when I do use a backgroundworker it simply won't work.




Re: Visual C# General Use VB6 COM component in backgroundworker

Peter Ritchie

Is this an ActiveX control, by chance






Re: Visual C# General Use VB6 COM component in backgroundworker

Scansys

It's an ActiveX Dll (Single Threaded).




Re: Visual C# General Use VB6 COM component in backgroundworker

Peter Ritchie

That might explain it, I believe ActiveX controls require an STA thread. How are you creating this ActiveX control and is it a child of the form






Re: Visual C# General Use VB6 COM component in backgroundworker

Scansys

De ActiveX does not contain any forms. It's a vb6 project with a couple of classes and modules. It's not an ocx, it's a dll.

If an ActiveX control requires a STA thread, why does it work in VS2005 in a backgroundworker

Thanks for helping me btw, really appreciated.