17 Replies Latest reply on Jan 14, 2013 11:41 AM by kirkktx

    Deploying a Custom C# GP-Tool on 10.1 Server

    elsinghorst-conterra-de-esridist
      Hi there,

      im trying to migrate my 10.0 GP-Services to 10.1
      As stated in http://resources.arcgis.com/en/help/main/10.1/index.html#/Deploying_custom_NET_and_C_tools/00570000008p000000/
      i am supposed to register the dll with 32bit esriregasm as well as with 64bit esriregasm.
      The problem im facing here is that the dll references the ESRI.ArcGIS.ADF assembly for the GPFunctionFactories Class in order to register the factory correctly. Unfortunately there is no ESRI.ArcGIS.ADF MSIL oder 64bit version, its only available as x86 in the GAC thus  the 64bit esriregasm fails to register my dll.
      Is there anything im missing here or a workaround for this issue?

      Thanks,
      Johannes
        • Re: Deploying a Custom C# GP-Tool on 10.1 Server
          nahmed-esristaff
          HI Johannes,

          At 10.0 the MSIL version for ESRI.ArcGIS.ADF was not available. The ADF available at 10.1 works for 'any cpu' - that is, it works for 32-bit as well as 64-bit. You just need to set the debug mode to 'Any CPU'.

          Could you please tell me what was your project setup at 10.0, especially:
          - Debug mode - 32-bit or Any CPU?
          - Was the reference to ESRI.ArcGIS.ADF set to False?

          The best approach would be to recompile the 10.0 project at 10.1 - if necessary remove the reference to ADF and add it back. Then follow the help doc. Let me know if you face any trouble. Thanks.

          Nobbir, Geoprocessing SDK
          • Re: Deploying a Custom C# GP-Tool on 10.1 Server
            kirkktx
            I had the same problem and was able to get the 64 bit version of EsriRegAsm to succeed by removing the reference to ESRI.ArcGIS.ADF, and adding a reference to ESRI.ArcGIS.ADF.Local, and recompiling.

            However, when I go into arcmap and run the tool, then right click to share as a geoprocessing package, it fails.

            I have both arcgis desktop and server installed on the same machine.

            I'm getting an error 00151.
            • Re: Deploying a Custom C# GP-Tool on 10.1 Server
              nahmed-esristaff
              Let me be clear the steps you have followed.

              1. You have compiled the C# project by removing the reference to ADF and adding it back AND
              - setting the Debug mode to 'Any CPU'.

              2. In order to run the tool in ArcMap you need to register it with the 32-bit EsriRegAsm located at ../Program Files (x86)/Common Files/ArcGIS/bin - if the registration fails then you have some problem with the project settings.

              Assuming step 2 succeeded.

              3: Run the tool in ArcMap. If you want to publish the tool it will fail as the Server does not know about it yet. So, don't publish now until performing step 4.

              4. Register the DLL with the 64-bit EsriRegAsm located at /Program Files/Common Files/ArcGIS/bin folder. If registration succeeds ..

              5. From ArcMap, share the result as a service.

              6. You should now be able to consume the service from any machine whether the DLL is registered with that machine.

              Let me know what error message  you get (if any).
              • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                kirkktx
                Hi NobbirAhmed -

                Here's my results:

                1. You have compiled the C# project by removing the reference to ADF and adding it back AND
                - setting the Debug mode to 'Any CPU'.
                yes

                2. In order to run the tool in ArcMap you need to register it with the 32-bit EsriRegAsm located at ../Program Files (x86)/Common Files/ArcGIS/bin - if the registration fails then you have some problem with the project settings.
                success (I did both 32 and 64 bit esriregasm).

                Assuming step 2 succeeded.

                3: Run the tool in ArcMap. If you want to publish the tool it will fail as the Server does not know about it yet. So, don't publish now until performing step 4.
                successfully ran


                4. Register the DLL with the 64-bit EsriRegAsm located at /Program Files/Common Files/ArcGIS/bin folder. If registration succeeds ..
                Did after step 2.

                5. From ArcMap, share the result as a service.
                Failure - error 00151 after running analyze.

                [ATTACH=CONFIG]17565[/ATTACH]
                6. You should now be able to consume the service from any machine whether the DLL is registered with that machine.

                Let me know what error message you get (if any).

                Could you please confirm that these steps work on a machine with both Desktop and server are installed?

                Thanks, Kirk
                • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                  khibma-esristaff
                  I'm not trying to hi-jack this, only offer advice/questions on the error 151:
                  This is a function tool - but have you wrapped it inside a script tool some how? Or are you actually running the function tool?
                  • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                    nahmed-esristaff
                    I'm not trying to hi-jack this


                    Kevin, rather, you have chipped in at the right moment.

                    Kirk, please check out the help for error 000151 which states "tool or function referenced is not supported for use in ArcGIS Server". The help topic for the error lists a number of tools/functions/scenarios where you may get this error.
                    • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                      kirkktx
                      Thanks for the fast response !

                      I'm not wrapping the tool in a script, do I need to do that?

                      I don't see anything in the list for error 00151 that would apply to my tool.
                      http://resources.arcgis.com/en/help/main/10.1/index.html#//00570000009n000000

                      The tool takes one argument (a long), and returns one argument (a long).

                      For  IGPFunctionName.MinimumProduct I'm returning esriProductCodeBasic ... is that correct?

                      This worked at 10.0.  Any word on whether this use case is supported when both desktop and server are installed on same machine?
                      • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                        khibma-esristaff
                        No, you dont need to do that (and actually shouldnt) - For a second I got my analyzers mixed up and was thinking about another one. Its good you confirmed that though.

                        To my knowledge, this analyzer which is impeding your publishing does not break into function tools to inspect them. I'm a little unsure how/why 151 would be thrown on a function tools.

                        Is there any chance you could share your compiled tool with us? I'll give it a try here. Again, this is strange, we have a test with a custom tool that does almost exactly what yours does and works without issue.
                        I cant comment on the license code, but dont suspect thats an issue, again because this analyzer isn't digging into the tool (I think).

                        If you can share the dll, please zip it up and send to me (khibma@esri.com).

                        thanks
                        • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                          nahmed-esristaff
                          Setting IGPFunctionName.MinimumProduct to esriProductCodeBasic should not fail. I'll try on my side with similar settings.

                          Meanwhile, to get going, just return true in your isLicensed method.

                                  public bool IsLicensed()
                                  {
                                      return true;
                                  }


                          Also, if possible send your project to Kevin - we'll see.
                          • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                            nahmed-esristaff
                            Okay, I tried with  your project and got the same error you are getting. I then looked into the project itself. The project organization kind of complex to me :(. So, I created a greatly simplified visual studio project just using your C# file inside the Tools folder (SleeperTool.cs). I can use this tool in Desktop and am able to publish it to ArcGIS Server and can consume the service without any error.

                            I have attached my project.

                            One question, what is the purpose of the AbstractGPTool class? Cannot you derive your SleeperTool class from IGPFunction2 directly as you did for GPFactory class where you derived the class from IGPFunctionFactory?
                            • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                              kirkktx
                              Hi Nobbir -

                              Thanks Nobbir! that does indeed work.  I may try out why the attached GP tool works in 10.0  but not in 10.1.  If I can't, then I'll need to do some re-architecting. 

                              Kirk
                              • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                                vasmel
                                Hi Kirk,

                                I have faced with the same problem and found solution. I was not able to publish GP Tool in ArcGIS 10.1 (that was working fine in ArcGIS 10.0) till I removed spaces from tool name (I saw in your sample you also have space in name).

                                I hope this will help for you too.

                                Vasyl
                                • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                                  briancoward
                                  I've been having this same issue.  Has anyone figured out a solution yet?  The final post on the thread suggested that by simply eliminating the spaces from the tool name would fix the incompatibility.  I haven't had spaces in the folder location of the esriregasm.exe file or the tool name itself.  When the term tool is referred to this means a .dll? 
                                  Any ideas or solutions would be appreciated.  Thanks,
                                  Brian
                                  • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                                    nahmed-esristaff
                                    Hi Brian,

                                    Could you please let us know what error message you are getting? Is the tool running fine on Desktop? Or faililng on both desktop and server?

                                    Can you send me your tool or at least the your code files (as *.zip) at nahmed@esri.com ?

                                    Thanks, Nobbir
                                    • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                                      kirkktx
                                      I've been having this same issue.  Has anyone figured out a solution yet?  The final post on the thread suggested that by simply eliminating the spaces from the tool name would fix the incompatibility.  I haven't had spaces in the folder location of the esriregasm.exe file or the tool name itself.  When the term tool is referred to this means a .dll? 


                                      Eliminating the spaces in my Name fixed one of my problems (Thanks Vasmel!).  (Spaces in DisplayName are ok).

                                      The other problem I had was that when I publish the gp service to a server from a different machine, the factor was not getting registered in the "Esri GeoProcessor Function Factory" category {FD939A4A-955D-4094-B440-77083E410F41}.   To view this, fire up Categories.exe in the bin folder.  I ended up copying the source to the server and re-building there, and running EsriRegasm.exe.

                                      Seems like a bug.  I would expect the gp service publisher to register via EsriRegasm.  (I'm on 10.11).
                                      • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                                        nahmed-esristaff
                                        You need to register the DLL on each machine (with Desktop installed) from where you'll publish the tool.

                                        Also, are you using categories.exe to register the DLL or just to view what's installed?
                                        • Re: Deploying a Custom C# GP-Tool on 10.1 Server
                                          kirkktx
                                          You need to register the DLL on each machine (with Desktop installed) from where you'll publish the tool.

                                          Also, are you using categories.exe to register the DLL or just to view what's installed?


                                          I'm calling EsriRegAsm (x86) to register.  Using Categories.exe only for viewing.