E_NOINTERFACE fail to cast IGeoDataset to ISaveAs

Discussion created by gracecai on Jul 5, 2012
Latest reply on Jul 10, 2012 by gracecai
Hi All,

I'm new to ArcObjects and C# and currently I'm trying to take an IRasterBand object and write it to file. The IRasterBand has been cast to IGeoDataset before this:

ISaveAs saveAs = (ISaveAs)EucDistRas; //this is the line that causes the failure
saveAs.SaveAs(targetName, targetWorkspace, "GRID");

The error I'm getting is as follows:

System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.Geodatabase.ISaveAs'. This operation failed because the QueryInterface call on the COM component for the interface with IID'{C7A9E97-597E-4A69-A872-29CB60B5E0DB}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

This procedure seems pretty standard. I've seen ESRI help docs that uses this code. I've read that dll registration might cause E_NOINTERFACE errors. So I've unregistered and then re-registered the ESRI.ArcGIS.Geodatabase dll (which ISaveAs resides in). But it doesn't seem to help. If anyone has any advice that would be much appreciated!

Thanks :]