What is the AppDomainSetup.SandboxInterop property?

I am using docs read for app domains in .net 3.5 and came across SandboxInterop . The docs say

Gets or sets a value that indicates whether interface caching is disabled for interop calls in the application domain so that QueryInterface is executed for every call.

But why would I want to disable QueryInterface caching?

(A quick google doesn't find anything that explains the way?)

+2


source to share


1 answer


In a typical operation, there is usually no reason to worry about caching QueryInterface queries.

However, other parties can create components in which a number of irreplaceable interfaces are tied to the component's operation. In addition, there are also outliers where an interface derived from a COM object has an implementation that can make it difficult to manage the object's lifetime.

For example, components written in ATL can be created using tearoff interfaces. These breaks are not available in the binary layout of the main object and are usually implemented on another hidden object that coordinates with its parent. Since a successful call to QueryInterface is implicitly considered a call to AddRef, the tearoff provider's lifespan can be extended to its intended version if the interface reference is cached. In addition, there might also be a case where an object only provides one break of a particular interface, with the intent that there is only one consumer through that interface. A cached copy can break this behavior if the same copy is served to two consumers when the goal is to deny the second request.

Finally, a more likely scenario is being able to track each QueryInterface for debugging or logging. The ability to turn off caching can allow someone to diagnose problems in which events might be lingering with him.



Here are the links to the tearoff interfaces for your reference.

Tear-Off ATL @CodeGuru interfaces

CComTearOffObject @MSDN Class

+2


source







All Articles