For DyanmicProgrammingModel (DPM) add-in projects, the file name of the host item code file generally matches the name of the host item. For example: in the SDK sample ShapeAppDynamicProgrammingModelCSharp the host item “Drawing1” would have a corresponding code file named either “Drawing1.cs” or “Drawing1.vb”. However, there is an exception to this rule. If a host item has been removed, then a new one added with the same name as the host item which has been removed, the DPM code file associated with the newly added host item will be named “HostItem#.xx”. For example: in the SDK sample if “Drawing3” was removed the corresponding code file “Drawing3.vb” would be removed from the DPM add-in project. Then, if a new drawing was added it would be named “Drawing3”; however, the corresponding code file would be “Drawing31.vb”.
This is due to a file which lingers once a host item has been removed. Of the three host item code files associated with each host item, namely HostItem.xx, HostItem.Designer.xml, and HostItem.Designer.xx, only the designer files are actually deleted when a host item is removed. The main, or visible, code file HostItem.xx is not deleted when the host item is. This residual file is removed from the DPM project; however, because the file still exists the new host item’s code file name is automatically appended with a number to avoid a naming collision.
Note: It is possible to use any valid name for the code file of a host item; this is specified in the first parameter “name” of the AddProjectHostItem methods.
//From DesgignTimeIntegration.AddProjectHostItemInternal
projectHostItem =
hostAdapter.ProjectHostItems.AddProjectHostItem(
itemName, //<== specify the host item code file name here
"Microsoft.VisualStudio.Tools.Applications.Samples.ShapeApp." + itemEntryPoint,
"Microsoft.VisualStudio.Tools.Applications.Runtime.IEntryPoint",
itemName, //cookie name
this.hostItemTemplatesPath + @"\" + languageFolder + @"\" + templateName);
For more information on the DyanmicProgrammingModel and the associated SDK sample please see the MSDN documentation Dynamically Creating and Modifying Host Items and Host Objects in an Add-in Project
Posted
Sep 23 2010, 11:00 AM
by
Melody