Hello dpomt,
Ji is not in office from today to the end of the week. I will help you with
the follow-up question.
Shared Add-in is a template that is provided by VS and doesn't require VSTO
to be installed. Add-in created using this approach inherits from
IDTExtensibility2 interface. I list the major commonness and differences
between Shared Add-in and VSTO Add-in at the bottom of this message. As a
quick tutorial of how to write a shared add-in targeting Word, please refer
to the KB article:
How to build an Office COM add-in by using Visual C# .NET
http://support.microsoft.com/kb/302901/en-us
If you would like to write a shared add-in instead of a VSTO add-in in this
task, please refer to these steps:
1. Create a shared add-in project targeting Word according to the steps 1-4
in KB 302901 (In Step 4.b, select Microsoft Word only)
2. Add the reference of Office Word Primary Interop Assembly (Right click
on the project -> Add Reference -> COM -> Microsoft Word 11/12.0 Object
Library)
3. Add the line
using Word = Microsoft.Office.Interop.Word;
into the Connect.cs file
4. Replace the line
private object applicationObject;
with
private Word.Application applicationObject;
5. In the OnConnection method, replace
applicationObject = application;
with
applicationObject = (Word.Application)application;
6. Copy & paste Ji's code of ThisAddIn_Startup into the OnStartupComplete
method.
7. Copy & paste Ji's rest code into Connect.cs. Replace the line
Globals.ThisAddIn.Application.Selection.InlineShapes.AddOLEObject(ref
missing, ref FileName, ref LinkToFile, ref DisplayAsIcon,
ref missing, ref missing, ref IconName, ref
missing);
with
applicationObject.Selection.InlineShapes.AddOLEObject(ref
missing, ref FileName, ref LinkToFile, ref DisplayAsIcon,
ref missing, ref missing, ref IconName, ref
missing);
8. Compile the project and run the setup.
=========================================
The commonness of the Shared Add-In and the VSTO Add-In is
1. Both of them are registered in the host application's registry key, for
example, HKCU\Software\Microsoft\Office\Word\Addins. After Office loading
them, they will both appear in the COM Add-in Dialog.
2. They both build upon the COM interface to do Office extensibility by
consuming the Office Object Model. And they can both add the extensible
UIs, like custom task pane, ribbon, outlook form region to Office
application.
=========================================
The major differences between the Shared Add-In and the VSTO Add-In.
1. As the name indicates, one Shared Add-In can be shared among several
different Office applications. So, it needs additional codes to judge the
host application in our Add-In. But in Visual Studio Tools for Office
Add-Ins, one Add-In can only serve one host application. So, in our Add-In,
what we are working on is strong typed host application. We do not need to
cast the application object to a specific one, or call its function via
late binding anymore.
2. To create the UI extensibility, ribbon, custom task pane, form region,
in the Shared Add-In, the programmers have to implement three interfaces,
Office.IRibbonExtensibility, Office.ICustomTaskPaneConsumer,
Outlook.FormRegionStartup. No matter creating which one of the extensible
UIs, we need a lot of manual work to write codes. But if we are using the
Visual Studio Tools for Office, everything is wrapped for us. We just need
to add a new Ribbon, UserControl, or FormRegion item into our VSTO Add-In
project. It is now supported to design these three UIs from the VSTO
designer. All we need to do are just dragging and dropping controls,
setting properties and double clicking to generate the event handle like we
are used to do in the Windows Form Designer.
3. Another importance difference is the security model. There is no
requirement for IDTExtensibility2 Shared Add-Ins to have any CAS policy
associated with them. So, before the Office can load the Shared Add-In, we
do not need to call the caspol to grant full trust to the Add-In assembly.
But as to VSTO, this security granting process is exactly necessary. The
VSTO uses the .NET security model to trust the Add-In managed assembly.
Consequently, it is more secure than the Shared Add-In. but takes some
extra work for us to do in the deployment.
4. Visual Studio Tools for Office creates a new AppDomain to load each of
the VSTO Add-Ins. So, it will not affect with each other. And the
programmers will not be worry about the "Outlook won't shut down" issue.
When the VSTO Add-in shuts down, the AppDomain gets unload and it will do
the clean for us.
If you have any other questions or concerns about this thread, please feel
free to tell me.
Have a very nice day!
Regards,
Jialiang Ge (
[email protected], remove 'online.')
Microsoft Online Community Support
=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================