mikrit

Exception from IDataset.get_Workspace().

Discussion created by mikrit on Feb 6, 2013
Latest reply on Feb 23, 2013 by rlwatson
Hello,
I have begun to work on a prototype of a plugin to ArcMap 10.1. It works on our computers and for some customers, but other customers get an exception. 

Exception message:

[INDENT]Error HRESULT E_FAIL has been returned from a call to a COM component.[/INDENT]

Top of call stack:

[INDENT]at ESRI.ArcGIS.Geodatabase.IDataset.get_Workspace()[/INDENT]

The C# code that triggers the exception is probably

[INDENT]
IDataLayer2 dataLayer = ...
IDataset dataset = dataLayer as IDataset;
try
{
[INDENT]  if (dataset != null
[INDENT]        && dataset.Category == "Shapefile Feature Class"
                    && dataset.Workspace.Type == esriWorkspaceType.esriFileSystemWorkspace)
[/INDENT]
                {
                ...
                }[/INDENT]
}
catch (Exception e)
{
...
}

[/INDENT]

So, it seems that the call to dataset.Workspace.Type throws an exception. What could cause that?

I noticed that there is a boolean method I could have called,

[INDENT]
if (dataset.Workspace.Exists())

[/INDENT]

but if I get an exception just by getting the Workspace, I assume that I would never reach the Exists() method.
And I don't see what non-existence means. Is it the same as "file not found"?

I would be grateful for any help.

Outcomes