Terry,
Here are responses to your questoins. I really suggest going through the walkthroughs before reading this because this covers some complicated DPM stuff that may be confusing and make the walkthorughs seem more confusing. "Simple" VSTA first, then DPM.
Hope this helps!
-Melody
1) Ok, I think I got this one since
it's easy enough. AddIn is a DLL, which will typically be created through
an AddIn project with one or more HostItem class files in it. This would
suggest that a typical simple application would load one AddIn that would have
HostItems in it for the various HostIemClassFiles in the appliation (Like one
application and multiple documents)
> AddIn is a DLL, which
will typically be created through an AddIn project
Correct.
> with one or more HostItem
class files in it.
HostItems are only for DPM. Add-ins do not have to be DPM.
All HostItems are Entry Points, but not all Entry Points are Host
Items: EntryPoint = Rectangle, HostItem
= Square. The difference between an
Entry Point and a Host Item is whether it is being used within the DPM context-
that is handled completely in the host.
Templates use one Entry Point. All projects based off this template (add-ins)
use this Entry Point. For a DPM project,
a project based off a template is used and the Entry Point of that template is
used as the “Host” (my term). This “Host”
Entry Point contains a collection of the Entry Point objects which are used as
Host Items. HostItems are added to it “Host”’s
collection and the “Host”’s collection may contain an empty (no HostItem class
file). HostObjects are then added to the
HostItems.
> This would suggest that a
typical simple application would load one AddIn
Even simple applications can load
multiple add-ins. The ShapeAppBasicCSharp
sample loads and discovers multiple add-ins.
For DPM you would (probably) want
only one DPM add-in; however, you could have multiple DPM add-ins, but it would
take a lot of management. Also, you can
load both nonDPM add-ins and DPM add-ins, they do not conflict with each other.
2) This one is still fuzzy. Are you saying that the HostID and it's related
registry tree (generated by the VSTA.exe /setup command) is simply describing
a DTE setup for the purposes of Creating and Opening a project
template? If this is true, then my Host ID (and the settings we put under
it in the registry) seem to be related to the IDE and where it stores and
retrieves it's file and information and has nothing to do with my HostItems
or HostObjects. In fact it doesn't really even seem to have any real
connection to my Host Application other then the fact that when I want to open
an IDE/DTE I need to tell it which HostID Entry to look under for behavioral
info.
>Are you saying that the HostID
and it's related registry tree (generated by the VSTA.exe /setup command) is
simply describing a DTE setup for the purposes of Creating and
Opening a project template?
Basically.
>If this is true, then my Host
ID (and the settings we put under it in the registry) seem to be related to the
IDE and where it stores and retrieves it's file and information and has nothing
to do with my HostItems or HostObjects.
In fact it doesn't really even seem to have any real connection to my
Host Application other then the fact that when I want to open an IDE/DTE I need
to tell it which HostID Entry to look under for behavioral info.
Correct- the VSTA registries are basically
for the IDE and creating/opening project templates. They have nothing to do with HostItems,
HostObjects, or the Host Application.
The ShapeApp DPM sample uses a
registry to hold the location of the Drawing.cs file. The registry they use for this is an application
registry- it is not in or related to the VSTA registry hives. IMO it would have been clearer to use a known
location instead of a registry value (the location of the file is written to
the registry in the setup file). The Drawing.cs
can be thought of as an “Item Template” just like other Item Templates in
Visual Studio. Item Templates are added
to a project, which is based off a Project Template.
3) Ok, so when I'm creating a DTE the first parameter I pass to the
ProviderGetDTE() method is just the HostID that will be used to get the
behaviroal information mentioned in #2 and doesn't imply any particular
HostItem or Object Model. In fact, not until I load a project using Solution.AddFromTemplate() do I actually
start to imply the use of any particular HostItem... and that's only because
I'm loading from a template that has a default HostItem specified.
> Ok, so when I'm creating a DTE the first parameter I pass to the
ProviderGetDTE() method is just the HostID that will be used to get the
behaviroal information mentioned in #2 and doesn't imply any particular
HostItem or Object Model.
Correct- ProviderGetDTE only deals with the DTE- it has nothing to do with
what templates or projects are loaded and nothing to do with DPM.
> In fact, not until I load a project using Solution.AddFromTemplate() do
I actually start to imply the use of any particular HostItem... and that's only
because I'm loading from a template that has a default HostItem specified.
No- Solution.AddFromTemplate loads a
template which has an Entry Point. The
Entry Point in the template will not be a Host Item, it will contain 0 or more
HostItems and the HostItems are programmatically added to the “Host” (Entry
Point of the template, my term).
Solution.AddFromTemplate is used to load a project based on a template-
it doesn’t matter whether or not the project from this will be used in a DPM
context.
4) So, each project template has one entry point, but once I load the
project template in the IDE I can add other HostItems to the template, in
addition to the one that already is in the project template. And, this
one that's in the template must have an entry point. My confusion is
around your statement about app and doc having to use different templates
(which would end up being different AddIns/Dlls) because they both need their
own entry point. Couldn't I have one project template with the app
HostItem specified as the entry point and then add multiple doc HostItems at
run-time to achieve the same affect?
> So, each project template has
one entry point
Yes.
> once I load the project template in the IDE I can add other HostItems
to the template, in addition to the one that already is in the project
template.
Project Templates do not contain HostItems- they must be added
programmatically (although you can include the file in the template that will
be the code representation of the HostItem
> My confusion is around your statement about app and doc having to use
different templates (which would end up being different AddIns/Dlls) because
they both need their own entry point.
Because each template can only contain one entry point Application level
add-ins and Document level add-ins each have their own template with the
corresponding entry point.
> Couldn't I have one project template with the app HostItem specified as
the entry point and then add multiple doc HostItems at run-time to achieve the
same affect?
You could have a project based off an application level template. This project would have an application level Entry
Point, and that Entry Point would serve as the “Host” for document HostItems. This would achieve the same effect through
DPM.
This is not the same as having an Application level template with Document
entry points in it- templates and projects based off them have only one entry
point. Note: it is possible to manually edit a template to
use both Application and Document level Entry Points; however, that is more
advanced than a typical DPM scenario- If you are interested in that, master DPM
first.
>Also I'm reading this from the SDK doco, which is using plurals to
suggest that you can have multiple entry points in a project:
>"Host items in add-in projects derive from entry
point classes in the proxy assembly. An entry point is a proxy type that
provides direct access to an object in the object model of the host
application. The entry point type is instantiated when the host application
loads an add-in. Typically, the entry point is a proxy for a host type at the
top of the object model hierarchy, such as an Application
class."
This applies to DPM projects- this is misleading when said in the context of
nonDPM add-ins which have only one entry point.
>Maybe this is all simpler than I'm making it out to me. Is it just
that when an AddIn loads, any HostItem Classes in it with an Entry Point will
be instantiated and fire their Startup events? Then if I programmatically
add some later in the same session, they won't get instantiated until the addin
is re-loaded?
> Is it just that when an AddIn loads, any HostItem Classes in it with an
Entry Point will be instantiated and fire their Startup events?
Sort of- DPM add-ins (multiple entry points) are loaded differently than
nonDPM add-ins
DPM style load:
// Initialize AddIn by calling into
functions of the AddIn EntryPoint instance.
// Because for Document AddIn,
Document and each drawing are all EntryPoint, We need to use
IMultipleEntryPoint.
IMultipleEntryPoint
multipleEntryPoint = addIn as IMultipleEntryPoint; //DPM
multipleEntryPoint.Initialize(addInToken[0].AssemblyName.FullName,
entrypointNameList, this.serviceProvider); //DPM
NonDPM style load:
// Initialize AddIn by calling into
functions of the AddIn EntryPoint instance.
addIn.Initialize(this.serviceProvider);
>Then if I programmatically add some later in the same session, they
won't get instantiated until the addin is re-loaded?
Correct.
5) I know this is new, but it seems important to the other points.
When I use ProjectGen, it requires me to pick a HostITem that will be the
"Base Type" so it seems that Project Templates must have a HostItem
in them in order to load them up. This does't make sense because I
thought an AddIn didn't have to have an particular HostItem in them. Is
this just becuase it's a template and it's not too valuable as a template
without at least one HostItem clas?
The BaseType is the Entry Point that will act as the “Host” to the “HostItems”. Here the choice in terminology is VERY unfortunate
since you are asked to pick a “Base type” and a “Host item name”. This “Host item name” is not referring to the
DPM HostItem- it is actually referring to the start up class and PrimaryCookie
(in the designer file) of the add-in.