C++/CLI: preventing garbage collection on managed wrapper of unmanaged resource

前端 未结 2 1919
忘了有多久
忘了有多久 2021-01-11 17:14

I have a C++ unmanaged class NativeDog that needs to be used from C#, so I\'ve create a wrapper class ManagedDog.

// unmanaged C++          


        
2条回答
  •  情话喂你
    2021-01-11 17:44

    You need a GC::KeepAlive() call in your FeedDogManaged function. Seems like it is an exact use case for that.

提交回复
热议问题