Compartilhar via


IVsCoTaskMemFreeMyStrings Interface

Used in association with certain other interfaces to indicate that strings returned from those interfaces should be freed by the caller.

Namespace:  Microsoft.VisualStudio.Shell.Interop
Assembly:  Microsoft.VisualStudio.Shell.Interop.8.0 (in Microsoft.VisualStudio.Shell.Interop.8.0.dll)

Syntax

'Declaration
<InterfaceTypeAttribute()> _
<GuidAttribute("47811DA4-330F-4EB5-9D14-BBC82773DA66")> _
Public Interface IVsCoTaskMemFreeMyStrings
[InterfaceTypeAttribute()]
[GuidAttribute("47811DA4-330F-4EB5-9D14-BBC82773DA66")]
public interface IVsCoTaskMemFreeMyStrings
[InterfaceTypeAttribute()]
[GuidAttribute(L"47811DA4-330F-4EB5-9D14-BBC82773DA66")]
public interface class IVsCoTaskMemFreeMyStrings
[<InterfaceTypeAttribute()>]
[<GuidAttribute("47811DA4-330F-4EB5-9D14-BBC82773DA66")>]
type IVsCoTaskMemFreeMyStrings =  interface end
public interface IVsCoTaskMemFreeMyStrings

Remarks

Normal COM rules require that any string passed back to a caller should be a copy of the string that the caller eventually disposes of. In other words, the caller is given ownership of the string and can dispose of the string when the caller sees fit.

Some interfaces in the Visual Studio extensibility space do not adhere to this rule of passing ownership to the caller for performance reasons. The callers of those special interfaces understand this change in the rule and do not attempt to dispose of the string. However in managed code, the parameter declarations for returned strings in those special interfaces imply always passing ownership of the string to the caller.

Managed code should implement the IVsCoTaskMemFreeMyStrings interface on those specific interfaces to indicate that the string really should be freed by the caller; otherwise, the caller does not free the string.

Notes to Implementers

Implement this interface on the same interfaces that contain the following methods. Implementing this interface indicates that the string returned from the following methods is to be disposed of by the caller; otherwise, the string is not disposed of.

Notes to Callers

If you have unmanaged code calling into managed code to one of the methods in the list shown in the Notes for Implementers section, call the QueryInterface method on the interface that contains the method to obtain the IVsCoTaskMemFreeMyStrings interface. If the IVsCoTaskMemFreeMyStrings interface can be obtained, you are responsible for freeing the string by calling the FreeCoTaskMem function (not the SysFreeString function). If you cannot obtain the IVsCoTaskMemFreeMyStrings interface, do not attempt to free the returned string.

See Also

Reference

Microsoft.VisualStudio.Shell.Interop Namespace