|
POST
|
I see that I incorrectly told you that your original installer class code was for registering an addin. That's not true, that is the code you need for your installer to kick off the component category registration for ArcGIS 10. The code I posted in that reply is for ArcGIS 9.3.1 and earlier. So, if you're deploying for 10 your original installer class code should work now that you corrected the registration code in your toolbar class. If you're deploying for 9.3.1 or earlier then I'm not sure what the problem might be. I think someone mentioned that the installer needs elevated permissions in order to run correctly. You can do this by right-clicking the setup.exe and choosing Run as Admin. I'm not at my work computer right now so I can't look at our installers to see what else we may be doing. Thanks a bunch for following along and contributing to this issue, Neil -- I appreciate the efforts. I can most certainly revert back to adding that Installer class back into the original assembly (where the ICommand/Toolbar classes are located), no problem! However, since that time I have used the walkthru as a guide and ditched that Installer and went with the recommended InvokeESRIRegAsm.dll/assembly approach (where they suggest to create a whole new project that contains the Installer class and you add this as a reference in the Setup project). I assume that I should remove this "new" Installer class/assembly and revert back to the original approach and continue with the updates I have made? Yes, this is all for ArcGIS10, I've finally had all clients moved on from 9.x!
... View more
08-15-2011
04:23 PM
|
0
|
0
|
530
|
|
POST
|
The component category registration code in your toolbar class is registering the toolbar in MxCommands. It should be registering it in MxCommandBars. I had really hoped it was (and still hope it is) something like this. Unfortunately, it still did not register either the Toolbar or Command. Here are the changes I made to the ToolbarDef class: #Region "ArcGIS Component Category Registrar generated code"
''' <summary>
''' Required method for ArcGIS Component Category registration -
''' Do not modify the contents of this method with the code editor.
''' </summary>
Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type)
Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
MxCommandBars.Register(regKey)
End Sub
''' <summary>
''' Required method for ArcGIS Component Category unregistration -
''' Do not modify the contents of this method with the code editor.
''' </summary>
Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type)
Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
MxCommandBars.Unregister(regKey)
End Sub
#End Region
... View more
08-15-2011
11:52 AM
|
0
|
0
|
1210
|
|
POST
|
Couldn't add the IToobarDef class code: <ComClass(FireToolBarDef.ClassId, FireToolBarDef.InterfaceId, FireToolBarDef.EventsId)> _
Public Class FireToolBarDef
Implements IToolBarDef
#Region "ArcGIS Component Category Registrar generated code"
''' <summary>
''' Required method for ArcGIS Component Category registration -
''' Do not modify the contents of this method with the code editor.
''' </summary>
Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type)
Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
MxCommands.Register(regKey)
End Sub
''' <summary>
''' Required method for ArcGIS Component Category unregistration -
''' Do not modify the contents of this method with the code editor.
''' </summary>
Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type)
Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
MxCommands.Unregister(regKey)
End Sub
#End Region
#End Region
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "3a781dce-3d88-40be-9351-e0f5d7cdfabf"
Public Const InterfaceId As String = "44fdf1a2-255e-4e36-8c09-e59c2d67182a"
Public Const EventsId As String = "a0b77313-5f65-4a41-9d90-779112341e6c"
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub
Public ReadOnly Property Caption() As String Implements ESRI.ArcGIS.SystemUI.IToolBarDef.Caption
Get
Return "Fire_V3.1"
End Get
End Property
Public Sub GetItemInfo(ByVal pos As Integer, ByVal itemDef As ESRI.ArcGIS.SystemUI.IItemDef) Implements ESRI.ArcGIS.SystemUI.IToolBarDef.GetItemInfo
Select Case pos
Case 0
itemDef.ID = "Fire_v3_1.clsFire"
itemDef.Group = True
End Select
End Sub
Public ReadOnly Property ItemCount() As Integer Implements ESRI.ArcGIS.SystemUI.IToolBarDef.ItemCount
Get
Return 1
End Get
End Property
Public ReadOnly Property Name() As String Implements ESRI.ArcGIS.SystemUI.IToolBarDef.Name
Get
Return "Fire_V3.1"
End Get
End Property
End Class
... View more
08-15-2011
11:09 AM
|
0
|
0
|
1210
|
|
POST
|
I am still not having any success with this. So, I went back and tried to get this to work on a WinXP platform and I still cannot get the COM component to register (however, I can load the ICommand/IToolbar Class by way of Customize-->Add From File-->.tlb on the XP workstation). So, here is everything I have. If there is anything blaringly incorrect, please let me know. clsFire.vb is the ICommand and IToolbar class. The app utilizesa UserControl (you'll see that I pass the app ref to it in the OnCreate): <ComClass(clsFire.ClassId, clsFire.InterfaceId, clsFire.EventsId), ProgId("Fire_v3_1.clsFire")> _
Public Class clsFire
'ProgId("Fire_v2_0.clsFire_v2")>
Implements ESRI.ArcGIS.SystemUI.ICommand
Implements ESRI.ArcGIS.SystemUI.IToolControl
Private m_pApp As IApplication
Private pDoc As IMxDocument
Private pMap As IMap
Private pLayer As IFeatureLayer
Private sLayerName As String
Private m_completionNotify As ICompletionNotify
Private m_FireUC As FireUC = New FireUC
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "01cf11bf-9fac-45e6-892a-4fc0fe020753"
Public Const InterfaceId As String = "732b6107-f31b-4078-b257-a718f725500e"
Public Const EventsId As String = "03223c0d-bf75-4b00-9cb8-966ed1428b18"
#End Region
#Region "ArcGIS Component Category Registrar generated code"
''' <summary>
''' Required method for ArcGIS Component Category registration -
''' Do not modify the contents of this method with the code editor.
''' </summary>
Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type)
Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
MxCommands.Register(regKey)
End Sub
''' <summary>
''' Required method for ArcGIS Component Category unregistration -
''' Do not modify the contents of this method with the code editor.
''' </summary>
Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type)
Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
MxCommands.Unregister(regKey)
End Sub
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub
Public ReadOnly Property Bitmap() As Integer Implements ESRI.ArcGIS.SystemUI.ICommand.Bitmap
Get
End Get
End Property
Public ReadOnly Property Caption() As String Implements ESRI.ArcGIS.SystemUI.ICommand.Caption
Get
Return "Fire_V3.1"
End Get
End Property
Public ReadOnly Property Category() As String Implements ESRI.ArcGIS.SystemUI.ICommand.Category
Get
Return "Fire_V3.1"
End Get
End Property
Public ReadOnly Property Checked() As Boolean Implements ESRI.ArcGIS.SystemUI.ICommand.Checked
Get
Return False
End Get
End Property
Public ReadOnly Property Enabled() As Boolean Implements ESRI.ArcGIS.SystemUI.ICommand.Enabled
Get
Return True
End Get
End Property
Public ReadOnly Property HelpContextID() As Integer Implements ESRI.ArcGIS.SystemUI.ICommand.HelpContextID
Get
End Get
End Property
Public ReadOnly Property HelpFile() As String Implements ESRI.ArcGIS.SystemUI.ICommand.HelpFile
Get
Return ""
End Get
End Property
Public ReadOnly Property Message() As String Implements ESRI.ArcGIS.SystemUI.ICommand.Message
Get
Return ""
End Get
End Property
Public ReadOnly Property Name() As String Implements ESRI.ArcGIS.SystemUI.ICommand.Name
Get
Return "Fire_V3.1" '"clsFire"
End Get
End Property
Public Sub OnCreate(ByVal hook As Object) Implements ESRI.ArcGIS.SystemUI.ICommand.OnCreate
Try
System.Windows.Forms.Application.EnableVisualStyles()
If Not (hook Is Nothing) Then
If TypeOf (hook) Is IMxApplication Then
m_pApp = CType(hook, IApplication)
m_FireUC.m_pApp = m_pApp
End If
End If
If Nothing Is m_FireUC Then
m_FireUC = New FireUC
m_FireUC.CreateControl()
End If
Catch ex As Exception
MsgBox(ex.ToString)
Exit Sub
End Try
End Sub
Public Sub OnClick() Implements ESRI.ArcGIS.SystemUI.ICommand.OnClick
End Sub
Public ReadOnly Property Tooltip() As String Implements ESRI.ArcGIS.SystemUI.ICommand.Tooltip
Get
Return "clsFire"
End Get
End Property
Public ReadOnly Property hWnd() As Integer Implements ESRI.ArcGIS.SystemUI.IToolControl.hWnd
Get
If Nothing Is m_FireUC Then
m_FireUC = New FireUC
m_FireUC.CreateControl()
End If
hWnd = m_FireUC.Handle.ToInt32
End Get
End Property
Public Function OnDrop(ByVal barType As ESRI.ArcGIS.SystemUI.esriCmdBarType) As Boolean Implements ESRI.ArcGIS.SystemUI.IToolControl.OnDrop
OnDrop = True
End Function
Public Sub OnFocus(ByVal complete As ESRI.ArcGIS.SystemUI.ICompletionNotify) Implements ESRI.ArcGIS.SystemUI.IToolControl.OnFocus
m_FireUC.CompletionNotify = complete
End Sub
End Class Then, I have followed the steps exactly as outlined here: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_deploy_a_custom_component_using_a_setup_project/00010000016r000000/ The InvokeESRIRegAsm project and Installer class are EXACTLY as described in the walkthru. The Setup Project itself has been created EXACTLY as outlined in the walkthru. Additionally, I have tried a multitude of various settings for the Install/Uninstall of the CustomActionData settings -- all of which produce the same behavior: The install runs without error, the directories are created and the referenced .dll's all copied over. But the registration does not work. I am not sure if there is something incorrect in the ICommand Name/Category/Caption properties of clsFire (which is why I have posted), but again the Toolbar does not show up in the Toolbars or Commands listings. I CAN register the files manually by way of Customize-->Add from file, but this is only on XP machines. This does not work on W7 machines, which is why I believe there is something else going wrong in my Setup or InvokeESRIRegAsm. Any more help is greatly appreciated.
... View more
08-15-2011
11:03 AM
|
0
|
0
|
1210
|
|
POST
|
Thanks for your detailed reply, Sean. I'll take another stab creating a new setup project (yes that's the link I was following originally) and try the settings you specify. Will keep you posted. Again --- thanks for your effort and help! James, I had to do a similar thing for an editor component this morning and found it didn't work either so i spent the last couple of hours working out whats going on. Fortunately its an 'easy' fix. Presumably you're using the procedure from: How to deploy a custom component using a setup project. If your deploying to a windows 7 machine then User Account Control (UAC) is probably turned on by default. This means that ESRIRegAsm.exe needs to run as administrator to actually do anything useful. Being part of the administrators group in windows 7 isnt good enough, the exe will need to run with elevated privileges (I usually set the program compatibility to run as administrator when manually working with dll's). To do this in your setup, add the following lines in the installer class (in the InvokeESRIRegAsm project) to read: ProcessInfo.UseShellExecute = false; ProcessInfo.Verb = "runas"; //aka run as administrator in the ExecuteCommand procedure. You'll also have to change the custom action scripts in the Setup project itself. Try entering /arg1="[TARGETDIR]\???.dll" for the install and uninstall custom action scripts. (replace ??? with your dll name of course). This works for me anyway. I'll have a chat to the SDK team about the doc...
... View more
08-04-2011
05:10 AM
|
0
|
0
|
1210
|
|
POST
|
Hello James, If your development environment is 32 bit and are deploying on 64 bit machine then build your application with the compiler option set to x86 in visual studio solution. ESRI components have to be compiled as x86, even though they are being deployed on 64 bit machine. Sumit Sumit, Thank you for your reply/input. The problem is that the client computer is 32-bit running W7 (I am told) and I am unsure what the dev machine is right now. What if the dev computer is 64-bit? What option should it be set to then? Thanks again! james
... View more
08-03-2011
02:05 PM
|
0
|
0
|
1210
|
|
POST
|
No, the component category registration code is the code that actually registers the class with the component categories. I must have an issue with my ICommand class (probably with the Category/Name properties, really don't know at this point). In any event.... I am getting a little desperate to get this installed on the client. Can anyone explain why I can manually register the .tlb (via Customize-->Add From File) without any problem EXCEPT on a Windows7 32-bit computer (using admin priv's account at login)? Edit: the ArcObjects SDK does not appear to be installed correctly as I cannot see any of the ArcGIS project templates or have the ArcGIS Component Category Registrar.
... View more
08-03-2011
05:02 AM
|
0
|
0
|
1210
|
|
POST
|
The class that implements IToolbarDef needs to have the component category registration code included in its code module. Do you mean to include the Sub Install/Uninstall in the IToolbarDef class? In other words, just copy over those 2 subs into the IToolbarDef class? How do they get initiated from within that class (Sub New)? Just a little confused on this. Make sure that code is registering with the MxCommandBars category. Just running the Categories.exe would show the list, right? Or is this no longer available with ArcGIS 10 install?
... View more
08-01-2011
06:49 AM
|
0
|
0
|
1459
|
|
POST
|
Neil, Thanks again for the code. Problem --- after adding the corrected code below, the client reports that the toolbar/extension did not show up in the list (by right-clicking the menu area) after running the .msi package (logged in as admin). They attempted to load the .tlb with "Add From File" again, which resulted in the same behavior --- it added the objects, but do not show up in the list to be able to "put a check" into the box to turn on the toolbar. Additonally, the .msi ran without any issues/hiccups and the installation folder is good! So, there are no problems with the install. Any help is appreciated. That is code to register an addin. The code for registering COM components is different. Imports System.ComponentModel
Imports System.Configuration.Install
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Imports System.IO
Imports System.Security.AccessControl
Public Class Installer1
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
'Add initialization code after the call to InitializeComponent
End Sub
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
Dim pRegSvr As New RegistrationServices
Try
MyBase.Install(stateSaver)
If Not pRegSvr.RegisterAssembly(MyBase.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase) Then
Throw New InstallException("COM registration failed. Some or all of the application classes are not properly registered in the ESRI component categories.")
End If
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message, "Install Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
Dim pRegSvr As New RegistrationServices
Try
MyBase.Uninstall(savedState)
If Not pRegSvr.UnregisterAssembly(MyBase.GetType().Assembly) Then
Throw New InstallException("COM unregistration failed. Some or all of the application classes were not properly removed from the ESRI component categories.")
End If
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message, "Uninstall Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class
... View more
08-01-2011
05:44 AM
|
0
|
0
|
1459
|
|
POST
|
That is code to register an addin. The code for registering COM components is different. Well hellsbells.... Thanks a bunch! I'll re-work the Installer class with the suggested code you provided.
... View more
07-20-2011
07:06 AM
|
0
|
0
|
1459
|
|
POST
|
Does the user have admin privileges on the machine? If not, Add from File won't work for them because it requires entries to be created in the system registry. Also, you can have your installer do this during install (it will also need admin rights). There's really no need to require the user to do anything other than run your installer then open ArcMap and turn on your toolbar. Neil, thanks for the feedback... Quite possibly that would be the issue because the InstallerClass (which contains the registration process code) doesn't seem to work. True, the person installing the .msi will log in as Admin then run the .msi --- but unsure if that same person is doing the "Add From File" (not likely as per your comments). You are right, the InstallerClass should be doing the registering! Just not sure if the code I have is working as expected. Here is the current code I am using in the InstallerClass to attempt to register the application on install/running the .msi: Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)
'Register the custom component.
'-----------------------------
'The default location of the ESRIRegAsm utility.
'Note how the whole string is embedded in quotes because of the spaces in the path.
Dim cmd1 As String = """" + Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) + "\ArcGIS\bin\ESRIRegAsm.exe" + """"
Dim part1 As String = Me.Context.Parameters.Item("arg1")
'Add the appropriate command line switches when invoking the ESRIRegAsm utility.
'In this case: /p:Desktop = means the ArcGIS Desktop product, /s = means a silent install.
Dim part2 As String = " /p:Desktop /s"
'It is important to embed the part1 in quotes in case there are any spaces in the path.
Dim cmd2 As String = """" + part1 + """" + part2
'Call the routing that will execute the ESRIRegAsm utility.
Dim exitCode As Integer = ExecuteCommand(cmd1, cmd2, 10000)
End Sub
Public Shared Function ExecuteCommand(ByVal Command1 As String, ByVal Command2 As String, ByVal Timeout As Integer) As Integer
'Set up a ProcessStartInfo using your path to the executable (Command1) and the command line arguments (Command2).
Dim ProcessInfo As ProcessStartInfo = New ProcessStartInfo(Command1, Command2)
ProcessInfo.CreateNoWindow = True
ProcessInfo.UseShellExecute = False
'Invoke the process.
Dim Process As Process = Process.Start(ProcessInfo)
Process.WaitForExit(Timeout)
'Finish.
Dim ExitCode As Integer = Process.ExitCode
Process.Close()
Return ExitCode
End Function
... View more
07-20-2011
06:52 AM
|
0
|
0
|
1459
|
|
POST
|
Bumping TTT hoping for some feedback this a.m.! Thanks
... View more
07-20-2011
05:08 AM
|
0
|
0
|
1459
|
|
POST
|
Has anyone run into deployment issues with a custom IToolBar/Command Class and a regular old Setup Project that builds an .msi on a Windows7 Pro (32bit I think) machine???? I have a user that for some reason cannot load the extension/toolbar (it's not really an extension exactly). But after running the .msi (no error), then choosing "Add From File" to load the .tlb, it still does not show up in the Commands list (so as to place a check to turn the toolbar on). This same .msi runs and the toolbar shows up just fine on all other installs. Thanks for any input.
... View more
07-19-2011
01:14 PM
|
0
|
22
|
3343
|
|
POST
|
As an alternative approach in addition to the suggestions already made, have you thought about returning the user account from the Windows Authentication (WindowsIdentity)? I use this in ALL of my ArcGIS applications because it's great to be able to throw around that user credential in many different components (for db logon, CrystalReporting, etc...). Anyway, below is a bit of code sampe that you might be able to use. Imports System.Data
Imports System.Data.SqlClient
Imports System.Security.Principal
Imports System
Public Class Form1
Private m_User As String
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim logonToken As IntPtr = LogonUser()
m_User = GetUserName(logonToken)
'Now you can use the m_User in your app for reporting/doing stuff with the current user that is
'logged into with Windows Authentication
End Sub
Private Function LogonUser() As IntPtr
Dim accountToken As IntPtr = WindowsIdentity.GetCurrent().Token
Return accountToken
End Function
Function GetUserName(ByVal logonToken As IntPtr) As String
Dim windowsIdentity As New WindowsIdentity(logonToken)
Dim parts() As String = Split(windowsIdentity.Name, "\")
Dim username As String = parts(1)
Return username
End Function
... View more
07-11-2011
09:50 AM
|
0
|
0
|
1178
|
|
POST
|
Hi, I am trying to loop through the field names and get field values when a feature is identified. Is there a way to programamtically loop through the field names from an identify wdialog and popultae the field values in a word document. I created a doc template with few bookmarks, so that I can popultae these field values to the bookmark in Word doc. Please help me. The most simple solution would be to setup a MS Word Doc for a MailMerge, where the datasource is the actual table or featureclass you are attempting to "loop thru". Then it's just a matter of opening that word document from your ArcGIS application.
... View more
06-14-2011
03:02 AM
|
0
|
0
|
1501
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-17-2020 10:47 AM | |
| 1 | 10-25-2022 11:46 AM | |
| 1 | 08-08-2022 01:40 PM | |
| 1 | 02-15-2019 08:21 AM | |
| 2 | 08-14-2023 07:14 AM |
| Online Status |
Offline
|
| Date Last Visited |
01-22-2025
02:28 PM
|