how to get document content using DFC in c#


I have documentum developer edition 6.6. I want to get document content (read content into stream) using DFC in c#. I have used following code

IDfId id = collection.getId("r_object_id");
IDfDocument doc = (IDfDocument) session.getObject(id);

but it throws following exception.

Exception: Unable to cast COM object of type 'System.__ComObject' to interface type 'DFCLib.IDfDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{EFAC2D68-175B-11D2-9927-006097C27C31}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

I also tried following method(it runs successfully) but i don't know how to read content into stream or memory stream.

IDfId id = collection.getId("r_object_id"); 
IDfSysObject sysObject = (IDfSysObject) session.getObject(id);
asked on Stack Overflow Sep 8, 2012 by khalid khan • edited Sep 8, 2012 by Julius Vainora

2 Answers


This will dump the file to a local filesystem path:

IDfId id = collection.getId("r_object_id"); 
IDfSysObject sysObject = (IDfSysObject) session.getObject(id);


Then you can open the file as a stream using standard .Net IO libraries, for example:

var stream = new System.IO.StreamReader(<path>)

I believe the DFC has some stream-based public methods (getContent?) but I have not seen them used successfully from .Net. However, I will suggest that you take a look at the DFS (Documentum Foundation Services) API instead of DFC. This is the supported API now and DFC is deprecated as a public API. DFS does have stream options when dealing with repository content.

You may also want to check if this answer is not sufficient for your needs.

answered on Stack Overflow Sep 18, 2012 by Brendan Hannemann

The exception says it cannot convert the COM Object to IDfDocument.

I would guess your target is not a document then.

It is weird for non-document sysobject to have a content, but it's still allowed. The content could then be read with getFile as suggested in the other answer.

answered on Stack Overflow Sep 20, 2012 by David Pierre

User contributions licensed under CC BY-SA 3.0