I have to communicate with a third party application and the only way to do so is by accessing the provided COM component. Because the interaction takes about 3 minutes it s mandatory that it takes place in the background. So what i tried to do is to add a reference the component with option "embedd interop-types" = true and to create a test that reads very basic data through the interface. The documented way to do so is by following Code:
System sys = new System();
if(Convert.ToBoolean(sys.Initialize()) && Convert.ToBoolean(sys.Login("John Smith", out userInstance)))
Project proj = new Project();
if (Convert.ToBoolean(proj.Open(sys, m_projName, m_scenarioName)))
someValue = proj.Name;
这一工作完全持续到背景工作者使用为止。 接着,我对第一行的法典有以下错误:
无法投放系统类型的COM物体。 这项行动之所以失败,是因为Query Interface呼吁COM部分参与国际交易日志的接口(1F5EB3E2-35F6-11D2-A191-0060083A260B}由于以下错误而失败:超负荷型图书馆/DLL。 (摘自HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRaire))。
我已尝试在没有任何成功的情况下重新修补该构成部分。
When using the BackgroundWorker the Thread Apartment Type obviously is MTA. The COM component has ThreadingModel set to apartment. If I understood this article http://msdn.microsoft.com/en-us/library/eaw10et3.aspx correctly the interop marshalling should take care of accessing the Objects.
没有人会想做些什么?