I want to build the project to create a tool with ArcObjects in Visual Studio. I get this error:
The command "esriRegasm.exe "...Project1.dll" /p:Desktop /s" exited with code -1.
I use C#, Visual Studio 2015, ArcObjects 10.5, ArcMap 10.5.
I looked at past questions with the same error (External tool (esriRegasm.exe) fails during build. Where in my VS project is it executed?).
I tried to solve the problem like this:
- tried to open the solution as an "adminimtrator" not just a user;
- run the
esriRegAsm.execommand from the command line. I tried in two ways. The first, as in the error in Visual Studio (picture 1) and the second, as per the instructions on the help.arcgis website. (picture 2); - tried to open the .csproj file, go to the end of the file, find the line
esriRegAsm.exe, delete it and rebuild the project.
None of this worked. How to build a project?
The esriregasm-tool is used to register your own commands, tools or extension for using in ArcGIS. It is usually defined as msbuild-task at the end of your csproj-file as follows:
As I get this eror on nearly every rebuild of my solution, I developed a couple of strategies to handle it.
First you can just build the project again. As this won´t invoke the forementioned targets - only on "Clean" or "Rebuild", but not on "Build" - the registration is not executed. However your assembly is created. You can still register it after being compiled, either by rightclicking on the dll-file and selecting Register, or by calling the following within the commandline:
Be aware that I omitted the
/s-flag in order to get more meaningul errors. You can also append the/e-switch for more verbose errors - which is not really much from my experience.Now look into folder where the ECFG-files are located. This is usually
%CommnonProgramFiles%\ArcGIS\Desktop<version>\Configuration\CATID. Make sure there is a file with the name of your assembly and the extensionecgf(it may also have some GUID at the beginning, e.g.{6d102248-13e2-40a0-8011-378543f63901}_MyAssembly.ecfg). This is just some zip-archieve, you can also unzip it and find an xml-file containing the GUIDs of your commands and tools. If registering the assembly didn´t work with the step mentioned before, you can just delete that ecfg-file and re-build (!!) your assembly. Then verify the file was created in that folder.If that still does not work, just delete your compiled assembly alltogether with an eventually existing ecfg-file and re-build again.