Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

In the unmanaged C++ client, why couldn I put the __gc modifier on the managed class?

0
Posted

In the unmanaged C++ client, why couldn I put the __gc modifier on the managed class?

0

The managed class in an unmanaged client has to be accessible by the unmanaged code in the application. When a managed class is marked for garbage collection, it can’t be accessed by any unmanaged code. The reverse situation is seen when you have a managed, garbage-collected class accessing an unmanaged class. It seems that managed, garbage-collected objects can reach outside the managed sandbox to access unmanaged objects. It’s just that the garbage-collected objects are located on the CLR-managed heap, which can’t be accessed from the outside. But objects on the managed CLR heap can use non garbage-collected pointers to access objects on the outside.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.