In the proxy file, all types and non-static members in non-classEntryPoint types are marked with a host attribute. The host attributes HostTypeAttribute and HostMemberAttribute are used to reconcile name changes. When there is no name change the attribute is unnecessary. The VSTA runtime uses this attribute, if available, to determine which type/member to call in the host.
For example, in the descriptor file if we change the method name for Application.NewDocument to Application.UpdatedName_NewDocument, the method in the proxy will be called Application.UpdatedName_NewDocument and will have the HostMemberAttribute "NewDocument". If this attribute is removed VSTA will attempt to call Application.UpdatedName_NewDocument in the host and this will fail. Similarly, if you change a HostMemberAttribute, VSTA will use the attribute name and the call will fail if no methods match the attribute name. Also, if you switch attribute names, the method for the attribute will be called. This may be useful in some cases.
Descriptor file:
(Application class)
<Method originalName="NewDocument" newName="UpdatedName_NewDocument" isExcluded="false">
<ReturnType>
<ExternalTypeReference isInterface="false" type="System.Void" />
</ReturnType>
</Method>
Proxy file:
(Application class)
[global::Microsoft.VisualStudio.Tools.Applications.Runtime.HostMemberAttribute("NewDocument", BindingFlags = global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.InvokeMethod)]
public virtual void UpdatedName_NewDocument() { throw new global::System.NotImplementedException(); }
(ApplicationEntryPoint class)
public virtual void UpdatedName_NewDocument()
{
this.RemoteObject.UpdatedName_NewDocument();
}
Add-in:
Me.UpdatedName_NewDocument
this.UpdatedName_NewDocument();
Posted
Oct 17 2008, 09:39 AM
by
Melody