Using DEWorkspaceType as ouput parameter in GP tools

Discussion created by Oyvind.Idlandgeodata-no-esridist Employee on Aug 8, 2013
I got a tool that supports writing to various feature workspaces (Shape, GDB and SDE). The user selects the desired workspace, and the tool creates feature classes. The ouput parameter is declared like this:

IGPParameterEdit3 parameter = new GPParameterClass();
parameter.Name = "out_workspace";
parameter.DisplayName = "Output workspace";
parameter.ParameterType = esriGPParameterType.esriGPParameterTypeRequired;
parameter.Direction = esriGPParameterDirection.esriGPParameterDirectionOutput;
parameter.DataType = new DEWorkspaceTypeClass();
parameter.Value = new DEWorkspaceClass();

This works fine for shape folders and file geodatabases. However, when I select an .sde file as workspace, the tool changes the file extension to .gdb (in the GUI, not on disk).

For example, when selecting "C:\somewhere\myfile.sde", it is shown as "C:\somewhere\myfile.gdb". The tool will of course fail.

However, when dragging the .sde file from the catalog tree to the tool, it shows correct file extension.

I am using ArcObjects/ArcGis 10.0 SP5.