PageRenderTime 56ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Visual Studio 2008/CppOfficeManagedCOMAddInShim/ReadMe.txt

#
Plain Text | 124 lines | 89 code | 35 blank | 0 comment | 0 complexity | 5e1191d271aeaed76bd67abe970032d7 MD5 | raw file
  1. =================================================================================
  2. Class Library APPLICATION : CppOfficeManagedCOMAddInShim Project Overview
  3. =================================================================================
  4. /////////////////////////////////////////////////////////////////////////////
  5. Overview:
  6. When we build a managed Office extension of any kind, we should ensure that
  7. our extension is isolated from other extensions that might be loaded into
  8. the application. The standard way to isolate our extension is to build a
  9. custom COM shim by using the COM Shim Wizard, a set of Visual Studio project
  10. wizards that helps you construct shims quickly and easily.
  11. /////////////////////////////////////////////////////////////////////////////
  12. Project Relation:
  13. CppOfficeManagedCOMAddInShim -> CSOfficeSharedAddIn
  14. CppOfficeManagedCOMAddInShim shims the managed COM AddIn CSOfficeSharedAddIn
  15. ManagedAggregator -> CppOfficeManagedCOMAddInShim
  16. ManagedAggregator loads and instantiates the add-in object, so that it can
  17. correctly aggregate this with the shim.
  18. /////////////////////////////////////////////////////////////////////////////
  19. Creation:
  20. Step1. Download the COM Shim Wizard template from the Microsoft download
  21. site, and install it so we can find the Shim AddIn template in Visual Studio,
  22. http://www.microsoft.com/downloads/details.aspx?FamilyId=3E43BF08-5008-4BB6-AA85-93C1D902470E&displaylang=en
  23. Step2. Create an Office COM Addin(Shared AddIn) to be shimed, and compile it.
  24. In this example, we use CSOfficeSharedAddIn as the target managed COM AddIn.
  25. It's a good practice to sign the managed COM AddIn dll with strong name.
  26. Step3. Create a new project. In the New Project dialog, navigate to the
  27. Visual C++ / COMShims node. Select the AddIn Shim project in right panel,
  28. name it as CppOfficeManagedCOMAddInShim and click OK.
  29. Step4. The COM Shim Wizard pops up. In the first page of the wizard, specify
  30. the output assembly of the managed COM AddIn project, and press Next button.
  31. (We may receive a warning dialog saying that the assembly needs to be signed
  32. as strong name if the target assembly was not signed. Just click Yes to
  33. ignore it)
  34. Step5. The second page is for configuration when our AddIn implements a
  35. secondary extensibility interface. We do not need this in this sample. Just
  36. press Next
  37. Step6. The third page is about Shared Add-in Details. In the page we can
  38. specify:
  39. Add-in Description
  40. Add-in Friendly Name
  41. Whether to load the Add-in when the host Office application starts
  42. Whether to install the Add-in to all users
  43. Add-in's host Office application
  44. In this example, we check the Microsoft Word, Visio, Publisher, Project,
  45. PowerPoint, Outlook, FrontPage, Excel, and Access checkboxes and, press Next
  46. to go on.
  47. Step7. The last is a summary page. Click Finish to create the AddIn Shim
  48. project. Accompanied with CppOfficeManagedCOMAddInShim, the wizard creates a
  49. .NET class library project named ManagedAggregator. The generated project
  50. also includes a final build task that runs Regsvr32.exe on the target DLL to
  51. register the shim, so you do not need to register it manually. The final
  52. build task copies the ManagedAggregator.dll into the target folder for the
  53. shim. It also copies the managed add-in assembly that you specified into the
  54. target folder for the shim, along with the configuration file for the add-in.
  55. The project dependencies are set so that the ManagedAggregator is built first,
  56. before the shim. If you add a shim project to an existing add-in solution,
  57. you should adjust the build dependencies, as appropriate.
  58. Step8. After the creation, compile the solution. You will find
  59. CSOfficeSharedAddIn in Office applications' COM Addins Dialog. And the
  60. location points to CppOfficeManagedCOMAddInShim.dll instead of mscoree.dll.
  61. /////////////////////////////////////////////////////////////////////////////
  62. Deployment:
  63. Step1. Navigate to the output folder of the CppOfficeManagedCOMAddInShim
  64. project. We can see the generated files:
  65. CppOfficeManagedCOMAddInShim.dll
  66. ManagedAggregator.dll
  67. CSOfficeSharedAddIn.dll
  68. Step2. Copy the above three files to the target computer where you want to
  69. deploy the Add-in.
  70. Step3. On the target computer, start a command prompt as administrator.
  71. Step4. Enter the command "regsvr32 CppOfficeManagedCOMAddInShim.dll" to
  72. register the shim dll.
  73. Step5. Open an Office application to verify the AddIn is shimed by
  74. CppOfficeManagedCOMAddInShim.dll.
  75. If you build a setup project for your add-in, you should add the primary
  76. output of both the shim and the ManagedAggregator projects to your setup. You
  77. should also change the value of the Register property for all three project
  78. outputs. Set this to vsdrpCOM for the shim DLL, and vsdrpDoNotRegister for
  79. both the original add-in DLL and the ManagedAggregator DLL.
  80. /////////////////////////////////////////////////////////////////////////////
  81. References:
  82. MSDN: Isolating Microsoft Office Extensions with the COM Shim Wizard Version
  83. 2.3.1
  84. http://msdn.microsoft.com/en-us/library/bb508939.aspx
  85. COM Shim Wizard Author's blog:
  86. http://blogs.msdn.com/andreww/archive/2007/07/05/updated-com-shim-wizards.aspx
  87. COM Shim Wizard download page:
  88. http://www.microsoft.com/downloads/details.aspx?FamilyId=3E43BF08-5008-4BB6-AA85-93C1D902470E&displaylang=en
  89. /////////////////////////////////////////////////////////////////////////////