Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This is my code to register my DLL (im using ArcMap 9.3)

Private Sub regDLL(ByVal dllName As String)
        Dim asm As System.Reflection.Assembly = System.Reflection.Assembly.LoadFile(dllName)
        Dim regAsm As New RegistrationServices()
        Dim bResult As Boolean = regAsm.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase)
    End Sub

This same code wont work in ArcGIS 10.1 since there is esriRegAsm. Anyone know how to convert it so dat it will work? I'm using Visual Studio 10.1.

share|improve this question

4 Answers 4

Assuming this is part of an installer/setup project see How to deploy a custom component using a setup project, particularly the section "Registering the CustomComponent .dll file using ESRIRegAsm.exe".

You could also try converting your project to an ArcMap add-in. See How to migrate from COM components to add-ins.

share|improve this answer
    
is their any other way to register it?i already tried that a week ago it works but its hard for me to update it every time there's changes in my main.dll. –  zxin Nov 8 '12 at 5:13
    
Can you convert it to an add-in? –  blah238 Nov 8 '12 at 9:41

Open command prompt and run as administrator Navigate to “C:\windows\microsoft.net\framework\v2.0.5777\” Run a command “regasm” with path “\YourDll.dll" /codebase You will get mesage 0 "Type registered succesfully"

share|improve this answer
    
It won't work with ArcMap 10.0 or later, you must use %CommonProgramFiles%\ArcGIS\bin\esriRegAsm.exe –  Goldorak84 Nov 12 '12 at 13:30
    
i agree..regasm won't work on ArcMap 10.0 and higher.. –  zxin Nov 20 '12 at 8:14

We had the same problem. To resolve it, we added the following lines in your setup. You could also create a batch file to run them.

on 64bit OS

"%commonprogramfiles(x86)%\ArcGIS\bin\esriRegasm.exe" "PATH TO YOUR DLL" /p:Desktop /s 

on 32bit os

"%commonprogramfiles%\ArcGIS\bin\esriRegasm.exe" "PATH TO YOUR DLL" /p:Desktop /s
share|improve this answer
    
i tried it and it registered but the dockable window i created were not loading but when i checked the dll in categories.exe in arcgis\bin the dll's were installed including my dockable window.,when i opend the arcmap the tools and toolbar is there but no dockable window., –  zxin Nov 13 '12 at 5:02
    
If your other controls are displayed, then your problem is probably with the dockable window itself. Is it registered in the good component category? Can you debug it initialization to see if an exception is launched? Consider adding try...catch blocks to help you locate the problem –  Goldorak84 Nov 13 '12 at 13:50
up vote 0 down vote accepted

thanks a lot guys especially to sir Goldorak84 and sir blah238 based on their statements i found a way to register my Arc Map 10.1 dll's programmatically using vb.net here's what i did

i added a class named "regESRIdll.vb" (i'll paste it below)

and upon clicking registration button i added this code

Dim directoryInfo As New System.IO.DirectoryInfo(Application.StartupPath.ToString)
    Dim fileInfos() As System.IO.FileInfo = directoryInfo.GetFiles()
    Dim iCount As Integer

    For Each fileInfo As System.IO.FileInfo In fileInfos
        For Each extension As String In allowedExtensions
            If UCase(extension) = UCase(fileInfo.Extension) Then

                        Dim myAssemblyName As Assembly = Assembly.LoadFile(fileInfo.FullName)
                        regESRIdll.Execute(True, myAssemblyName) '====to unregister the dll change True to False

                iCount += 1
            End If
        Next
    Next

and don't forget to declare regESRIdll as new regESRIdll '========================================================================== Imports System.IO

Public Class regESRIdll

Public Enum Product

    Desktop

    Engine

End Enum


Public Sub Execute(ByVal register As Boolean, ByVal assemply As System.Reflection.Assembly, Optional ByVal product As Product = Product.Desktop, Optional ByVal timeout As Integer = 10000)
    ' Configure the process to execute the command
    Dim process As New Process()
    process.StartInfo.FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles), "ArcGIS\bin\ESRIRegAsm.exe")
    process.StartInfo.Arguments = String.Format(If(register, """{0}"" /p:{1} /s", """{0}"" /p:{1} /u /s"), assemply.Location, product)

    ' Invoke the process
    process.Start()
    process.WaitForExit(timeout)

    ' Finish
    Dim exitCode As Integer = process.ExitCode
    process.Close()
    If exitCode <> 0 Then
        Throw New Exception(If(register, "ESRI registration failed", "ESRI unregistration failed"))
    End If
End Sub

End Class

'===============================

-END

thanks again, i hope this posts will help those who will encounter the same problem in the near future.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.