C ++ / CLI,Unmanaged to Managed callback,不使用网桥或固定指针。




我有一个相当有趣的问题。我有一个无法管理的c ++类

需要通过回调将信息传递给托管的c ++,

在托管的c ++上提供一层c#ultimatley retreiving

数据。目前所有的c ++代码仍然在.NET 1.1中,因此我们使用包含在_gc c ++类中的_nogc桥类来获得
,以便

为此提供便利互操作。


但是我们已经把所有不是c ++的东西都转换成了.NET 2.0,并且很乐意将b ++转换为c ++,但是我是不知道如何克服这个问题。我的问题......


1.)C ++ / CLI不支持这种_nogc桥类的想法。


2.)我需要有这个指针用于

应用程序的生命周期,这意味着我需要将其固定,这是一个非常糟糕的想法,因为它将被锁定在堆积为

持续时间。


所以我不知道如何克服这个问题。任何帮助都会非常值得赞赏。

Hi,

I have a rather interesting problem. I have a unmanged c++ class
which needs to communicate information to managed c++ via callbacks,
with a layer of c# on top of the managed c++ ultimatley retreiving the
data. Presently all of the c++ code is still in .NET 1.1, so we''re
using a _nogc bridge class wrapped in a _gc c++ class in order to
facilitate this interop.

But we''ve converted everything not c++ to .NET 2.0 and would love to
convert the c++ as well, but I''m not sure how to overcome this
problem. My issues...

1.) C++/CLI does not support this _nogc bridge class idea.

2.)I would need to have this pointer around for the life of the
application, which means I would need to pin it, which is a
ridiculously bad idea considering it will be locked on the heap for
the duration.

So I''m not sure how to overcome this. Any help would be greatly
appreciated.



 1 条回答

net