如何避免获得COM对象重新进入锁定的效果. [英] How to avoid access to COM object re-entrance locking effect.

查看:53
本文介绍了如何避免获得COM对象重新进入锁定的效果.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我有一个用c ++编写的com对象(基于IDispatch接口).我可以在vb6甚至在c#(VS2010)中愉快地创建一个实例.

问题如下:
我有一个控制台应用程序,可以处理我的对象的实例.
目标是启动一个vb6 activex.dll,并通过显示表单的ActiveX.dll方法传递该对象.它工作正常,但是当我退出负责ActiveX实例化的函数时,单击窗体上的按钮以访问我的对象实例(在本地分配给变量)时,我得到了锁定效果.

我该如何解决这种连锁问题.我希望使用xxx.invoke(...),但object或Type没有这种方法.

我想这与托管和非托管代码有关,但实际上不知道如何解决该问题.

要创建主COM对象,请使用:

Hello everyone.

I have a com object written in c++ (based on IDispatch interface). I can create an instance happily in vb6 and even in c# (VS2010).

The problem is the following:
I have a console application which handles an instance of my object.
The goal is to launch a vb6 activex.dll with this object passed via a method of this activex.dll which display a form. It works fine but when I quit the function responsible of the activex instantiation, I got a locking effect when I click on a button on the form to access to my object instance assigned to a variable locally.

How could I solve this interlock situation. I was hoping to use xxx.invoke(...) but object or Type do not have this method.

I suppose this is related to managed and un-managed code but does not know actually how to solve that issue.

To create the master COM object I am using :

private bool CreateCOMObject(string ComponentClassName)
{
    bool bRet = false;

    _VB6DocType = System.Type.GetTypeFromProgID(ComponentClassName);
    _VB6Control = System.Activator.CreateInstance(_VB6DocType);

    bRet = true;

    return bRet;
}



也许您已经遇到过这样的问题?
提前非常感谢您.
最好的问候.
Michel



Maybe do you have already encontoured such an issue ?
Thank you very much in advance.
Best regards.
Michel

推荐答案

我猜*这是一个单元线程问题

看看异步使用STA COM对象 [
I''d *guess* it''s an apartment threading issue

Have a look at Use STA COM Objects Asynchronously[^] or change the threading model on your object


这篇关于如何避免获得COM对象重新进入锁定的效果.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆