4

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 C#.net 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);
Julius Vainora
  • 47,421
  • 9
  • 90
  • 102
khalid khan
  • 73
  • 2
  • 5

2 Answers2

0

This will dump the file to a local filesystem path:

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

sysObject.getFile(<path>)

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 http://developer.emc.com if this answer is not sufficient for your needs.

Brendan Hannemann
  • 2,084
  • 1
  • 18
  • 33
0

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.

David Pierre
  • 9,459
  • 4
  • 40
  • 32