Defining Entry Points and Other Proxy Changes
You can modify the types that ProxyGen.exe generates in the proxy code file by changing elements and attributes in the proxy descriptor file. You must specify at least one proxy type as an entry point for the object model of the host application. You can also make other optional changes to proxy types, such as hiding or renaming types or members, changing the type of return values, or applying new attributes. These kinds of changes modify the object model that is exposed to add-in developers without changing the object model source code in the host application.
All changes you make to the proxy descriptor file must conform to the XML schema file ProxyGenDescriptorv2.xsd. For more information, see ProxyGen Descriptor Schema Reference.
Understanding Entry Points
An entry point is a type that is instantiated when the host application loads an add-in. The entry point also contains methods that can be called by the host application to initialize the add-in. Typically, the entry point is a proxy for a host type that lives at the top of the object model hierarchy, such as an Application class that represents the host application, or a Document class that represents a document in the application.
For proxies that are generated from managed assemblies, you can specify a class or an interface as an entry point. For proxies that are generated from COM type libraries, you can specify only classes as entry points.
If your object model is implemented in multiple assemblies or type libraries, you do not have to specify an entry point in every proxy descriptor file that you generate. However, at least one of the proxy descriptor files must have an entry point (although you can optionally specify entry points in multiple descriptor files).
An entry point is also the base class for a host item in the add-in developer's project. A host item is a class that provides a starting point for add-in developers to write their code, and is the class that add-in developers use to obtain all other objects that they use to automate the host application. For more information about host items, see Creating Project Templates Using the Project Template Generation Tool (Projectgen.exe).
Specifying an Entry Point
To specify a class or interface as an entry point, set the isAddInEntryPoint attribute to true for the element in the proxy descriptor file that represents the class or interface. Then, run ProxyGen.exe again and pass in the revised proxy descriptor file as an input parameter to generate the proxy code file. For more information, see Creating Proxies.
In the generated proxy code file, ProxyGen.exe generates an entry point class that can be discovered and instantiated by the host application. For more information, see Architecture of Generated Proxy Code. For walkthroughs that demonstrate how to specify an entry point, see Walkthrough: Creating a Proxy Assembly.
Optional Proxy Changes
You can make the following optional changes to the proxy descriptor file. These changes specify how the proxy types and members are generated in the proxy code file.
Task |
Description |
---|---|
To change the namespace of a type |
Use the newNamespace attribute of the element that represents the type. |
To hide a type or member from the proxy assembly |
Use the isExcluded attribute of the element that represents the type or member. |
To rename a type or member |
Use the newName attribute of the element that represents the type or member. |
To add a custom attribute |
To add an attribute to a return value, add a new ReturnValueAttribute element to a parent element that represents the member that has the return value. To add an attribute to a type or a member, add a new Attribute element to a parent element that represents the type or member (that is, a class, delegate, enumeration, event, exception, interface, method, parameter, property, or struct). |
See Also
Tasks
Walkthrough: Creating a Proxy Assembly
Concepts
ProxyGen Descriptor Schema Reference