• How to share a custom ArcMap command (DLL)


    http://edndoc.esri.com/arcobjects/9.2/NET/33903846-919f-48b4-a4b1-ef97680ddb7b.htm AssumptionsBefore proceeding, review the following assumptions:
    • Youhave created a Visual Studio 2005 (VS2005) project that has an ArcMapcommand using the integrated development environment (IDE) features ofthe ArcGIS Desktop software development kit (SDK) on a computercalled DevelopmentPC.
    • The DevelopmentPC computer has a VS2005 project located at C:\DeployTest1 with the following file:
      • C:\DeployTest1\bin\Debug\DeployTest1.dll
    • Youwant to deploy your custom ArcMap command on another Windows basedcomputer with the .NET Framework installed named TargetPC, which hasArcMap installed but not VS2005.
    • Yourdeployment is essentially a shrink-wrap type of customization. Otherdevelopers will not consume or extend your custom .dll via additionalprogramming.
    Gather the prerequisite informationObtainthe necessary information to make the deployment possible. Thefollowing are two critical pieces of information that must be obtained:
    • Determine the component category to be registered with ArcMap for your class
    • Obtain the name category and caption of the deployable command
    Determine the component categoryDo the following to determine the component category registered with ArcMap:
    1. Onthe DevelopmentPC computer, open your VS2005 DeployTest1project and click Project and Add Component Category menus.  See thefollowing screen shot:
    2. Inthe ArcGIS Component Category Registrar dialog box, select theappropriate Class that has your customization and look for any checkedcategories. In this example, our customization is in theDeployTest1.CommandDeployTest1 class and the ArcMap Command is checked.Notice under the ArcMap Command Properties section is the Caption valueis ESRI MxCommands.
    Anotherway to ensure that you have the correct component category registeredis to scan the class code in the VS2005 project for theArcGISCategoryRegistration method to find this information. In thefollowing screen shot, notice how in the CommandDeployTest1 class thecommand is registered with MxCommands:  Obtain the name category and captionDo the following to obtain the name category and caption of the deployable command:
    1. Onthe DevelopmentPC computer, scan the code in the VS2005 project for theNew method to obtain the category and caption of the command. In thisexample, the command's category is CategoryDeployTest1 and the captionis CaptionDeployTest1. See the following screen shot:
    You now have all the prerequisites to proceed with the remaining of your test deployment. Test the DeploymentNowyou can begin the process to copy the necessary files to the target PC,register them with the Windows Registry, register them in ArcMap'scategories, and finally add the command to ArcMap.  Copy the necessary files from the development to target computer
    1. On the TargetPC, create a new directory and name it C:\deployment_test.
     
    1. Copy the necessary deployment files onto your target computer. Specifically, copy the files from the DevelopmentPC:
    C:\DeployTest1\bin\Debug\DeployTest1.dll to the TargetPC in the following locations: C:\deployment_test\DeployTest1.dll Use regasm.exe utility to register the necessary files with the Registry
    1. Onthe TargetPC computer, use the Microsoft Regasm.exe utility (usinga Windows command prompt) to register the deployed files appropriatelywith the operating system. Do this by issuing the following syntax fromthe command prompt on the DeploymentPC:
    regasm "C:\deployment_test\DeployTest1.dll" /codebase Ifyour .NET code project did not use a strongly typed assembly name, awarning message similar to the following screen shot appears:  Thewarning message will not impact the component registration, but when itis time to deploy your application in a commercial setting, considerstrongly typing your assemblies. For more information on how tostrongly type assemblies, see Create Strong Name Key Dialog Box on the MSDN Web site. If you use a strongly typed name you do not need to use the /codebase switch in the Regasm.exe utility.  For more information on all of the options of the Regasm.exe utility by Microsoft see the MSDN article Assembly Registration Tool (Regasm.exe).Note: To open a command prompt in Microsoft Windows and use the Regasm.exe utility:
    • Click Start, Run, type cmd at the command prompt, then press Enter.
    • Using DOScommands, navigate to the Microsoft .NET Framework installationlocation; for example, on Windows XP navigateto: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727; on Windows NTnavigate to: C:\WINNT\Microsoft.NET\Framework\v2.0.50727).
    Verify the component category registration with ArcMap Theprevious step of registering your files using Regasm.exe should be allthat is needed to have your ArcGIS Visual Studio IDE Integrationfeature customization deployed on a target machine running Windows withthe .NET Framework. You can however verify that this is true byusing the ESRI utility, categories.exe. This will verify that thecomponent category registration was successful.
    1. On the TargetPC computer, use Windows Explorer to locate and start C:\Program Files\ArcGIS\bin\categories.exe.
    2. Navigateto the Component Object Model (COM) category group that yourcustomization should be registered with. In our example scroll down tothe ESRI MxCommands and expand the node as demonstrated in thefollowing screen shot:
    You know to select ESRI MxCommands because this is one of the critical pieces of information in Step 1. You should see your customization available in list of the particular ArcGIS component category.Thename DeployTest1.CommandDeployTest1 matches the name of the class inthe dropdown of the ArcGIS Component Category Registrar dialog in theVS2005 project on the DevelopmentPC as shown in the screen shot in Step 1 of the section Determine the Component Category.Add the new ArcMap command Open ArcMap on the TargetPC and add your customization to the Graphical User Interface (GUI).
    1. In ArcMap, click Tools and Customize.
    2. In the Customize dialog box, click the Commands tab. Scroll down and click CategoryDeployTest1 from the Categories list.
    3. Drag CaptionDeployTest1 onto the GUI to test the functionality.
    See the following screen shot:  Inthe preceding screen shot, the category is CategoryDeployTest1 and thecommand is CaptionDeployTest1. This matches the code screen shot in Step 1 under the Obtain the name category and caption section.Thereare numerous options to consider when deploying an ArcObjects basedapplication. This topic only suggested one option to provide a generalworkflow. Ifyou need to have your customization be consumed by other 3rd partydevelopers (i.e. they will write custom applications against yourobjects you create), then you may also need to issue additional syntaxwith the Regasm.exe utility by using the /tlb switch to create andregister any COM .tlb files. This would enable other developers toconsume and extend your customization. See Also:Deploying in-process components (DLLs) How to register classes in COM component categories About the ArcGIS Component Category Registrar dialog box How to register .NET components with COM Deploying EXEs
  • 相关阅读:
    常量
    html5+css3 background-clip 技巧
    AJAX小结
    使用jquery来完成AJAX操作
    linux命令 cp 递归复制 带权限复制
    html标记语言 --超链接
    html标记语言 --图像标记
    html标记语言 --文本标记
    [转]linux如何修改文件或目录的权限(chmod)
    html标记语言 --格式标记
  • 原文地址:https://www.cnblogs.com/adodo1/p/4327308.html
Copyright © 2020-2023  润新知