Add ArcGIS Toolbox Reference - .Net target version of created DLL?

1365
5
Jump to solution
05-16-2013 12:55 PM
TerryGiles
Occasional Contributor III
I'm currently working on an Add-In in which I'll need to do some geoprocessing.
In the ArcObjects samples (here) there's one that show how to queue up multiple geoprocessing tools to run in the background and not have existing data for inputs (e.g. tool2 uses tool1's output).  This looks like something I'll need to implement, but when trying it today I hit an issue - some of the tools I need to run are in custom toolboxes so I can only execute them using GP.executeasync(string name, varArray params).  I remembered that you can add a reference to an ArcGIS Toolbox in your Visual Studio project.  I tried this, but the DLL created from the process has a Runtime version of 4 and I'm working in 3.5...  2 questions about this process:

1.  Is there a way to control the .Net version the DLL is compiled against?  Is it based on the version tied to the version of Visual Studio?
2.  Will users of the Add-In still need the actual .tbx file I created the DLL from & in the exact same file location?

Thanks, Terry
0 Kudos
1 Solution

Accepted Solutions
FridjofSchmidt
Occasional Contributor
I haven't tried it yet but seems like instead of using this-:
private Queue<IGPProcess> _myGPToolsToExecute = new Queue<IGPProcess>(); ...         _myGPToolsToExecute.Enqueue(bufferTool);         _myGPToolsToExecute.Enqueue(clipTool);         _gp.ExecuteAsync(_myGPToolsToExecute.Dequeue());


why not this -

private Queue<string> _myGPToolsToExecute = new Queue<string>(); private Queue<IVariantArray> _myGPToolsParams = new Queue<IVariantArray>(); ...           _myGPToolsToExecute.Enqueue(bufferTool);         _myGPToolsParams .Enqueue(bufferParams);         _myGPToolsToExecute.Enqueue(clipTool);         _myGPToolsParams .Enqueue(clipParams);         _gp.ExecuteAsync(_myGPToolsToExecute.Dequeue(),myGPToolsParams.Dequeue());


Why not write a small class MyTool with 2 public properties string Name and IVariantArray Parameters, and then define the queue as Queue<MyTool>?


I'm still curious about my 2 questions re: converting the .tbx to a DLL though if anyone has thoughts on that.


I've been using the ArcGIS Toolbox References in some integration tests, but actually I'm not happy with them, therefore I'm going back to the previous syntax with tool name + IVariantArray. I also observe that the tool DLL uses the .NET runtime 4.0, but what's worse in my case is that the assembly builder seems to hardcode the toolbox location into the DLL. Therefore, if you move the toolbox somewhere else, the DLL won't help you any more.

View solution in original post

0 Kudos
5 Replies
TerryGiles
Occasional Contributor III
I haven't tried it yet but seems like instead of using this-:
private Queue<IGPProcess> _myGPToolsToExecute = new Queue<IGPProcess>();
...
        _myGPToolsToExecute.Enqueue(bufferTool);
        _myGPToolsToExecute.Enqueue(clipTool);
        _gp.ExecuteAsync(_myGPToolsToExecute.Dequeue());


why not this -

private Queue<string> _myGPToolsToExecute = new Queue<string>();
private Queue<IVariantArray> _myGPToolsParams = new Queue<IVariantArray>();
...


        _myGPToolsToExecute.Enqueue(bufferTool);
        _myGPToolsParams .Enqueue(bufferParams);
        _myGPToolsToExecute.Enqueue(clipTool);
        _myGPToolsParams .Enqueue(clipParams);
        _gp.ExecuteAsync(_myGPToolsToExecute.Dequeue(),myGPToolsParams.Dequeue());


I'm still curious about my 2 questions re: converting the .tbx to a DLL though if anyone has thoughts on that.
0 Kudos
RichardWatson
Frequent Contributor
Is there a way to control the .Net version the DLL is compiled against?


You specify the version of the .NET framework to use when you create the project in Visual Studio.  You can see what it is, and change if you wish, in the project properties.  Just right click on the project in solution explorer and select properties.
0 Kudos
TerryGiles
Occasional Contributor III
Richard,

My Add-In project is targeting 3.5 & that's what it shows in the properties, which is what I thought the Add Toolbox Reference what honor but it doesn't seem to be the case.  I think the context menu in Visual Studio is really running the GPAssemblyBuilder.exe in C:\Program Files (x86)\ArcGIS\DeveloperKit10.1\IDEIntegration\VisualStudio\bin.  I tried running that via command line but there doesn't seem to be any switches for the output target framework either.
0 Kudos
FridjofSchmidt
Occasional Contributor
I haven't tried it yet but seems like instead of using this-:
private Queue<IGPProcess> _myGPToolsToExecute = new Queue<IGPProcess>(); ...         _myGPToolsToExecute.Enqueue(bufferTool);         _myGPToolsToExecute.Enqueue(clipTool);         _gp.ExecuteAsync(_myGPToolsToExecute.Dequeue());


why not this -

private Queue<string> _myGPToolsToExecute = new Queue<string>(); private Queue<IVariantArray> _myGPToolsParams = new Queue<IVariantArray>(); ...           _myGPToolsToExecute.Enqueue(bufferTool);         _myGPToolsParams .Enqueue(bufferParams);         _myGPToolsToExecute.Enqueue(clipTool);         _myGPToolsParams .Enqueue(clipParams);         _gp.ExecuteAsync(_myGPToolsToExecute.Dequeue(),myGPToolsParams.Dequeue());


Why not write a small class MyTool with 2 public properties string Name and IVariantArray Parameters, and then define the queue as Queue<MyTool>?


I'm still curious about my 2 questions re: converting the .tbx to a DLL though if anyone has thoughts on that.


I've been using the ArcGIS Toolbox References in some integration tests, but actually I'm not happy with them, therefore I'm going back to the previous syntax with tool name + IVariantArray. I also observe that the tool DLL uses the .NET runtime 4.0, but what's worse in my case is that the assembly builder seems to hardcode the toolbox location into the DLL. Therefore, if you move the toolbox somewhere else, the DLL won't help you any more.
0 Kudos
TerryGiles
Occasional Contributor III
Why not write a small class MyTool with 2 public properties string Name and IVariantArray Parameters, and then define the queue as Queue<MyTool>?


That would work too.  May take that idea and add some properties to the class for setting props on the GeoProcessor such as OverwriteOutput as well.

I also observe that the tool DLL uses the .NET runtime 4.0, but what's worse in my case is that the assembly builder seems to hardcode the toolbox location into the DLL. Therefore, if you move the toolbox somewhere else, the DLL won't help you any more.


Thanks for the information.  The tbx I was looking at can in fact be in different locations depending if the OS is 32 or 64bit.  I'll stick to using the string name & ivariantarray params for now.

Terry
0 Kudos