I created a dll in C # that takes as a parameter the name of the Lotus Domino server, the name of the data base lotus notes and the UNID of a document of this base.The goal of this dll is to open in read mode the document having the UNID passed as parameter and then print the document via the printer installed on the machine. the problem is that sometimes the DLL instead of open the Document notes, it opens the attachment attached in this document and generates the following exception:
COMException.Message = L'objet invoqué s'est déconnecté de ses clients. (Exception de HRESULT : 0x80010108 (RPC_E_DISCONNECTED))
COMException.ErrorCode = -2147417848
COMException.ToString = System.Runtime.InteropServices.COMException (0x80010108): L'objet invoqu‚ s'est d‚connect‚ de ses clients. (Exception de HRESULT : 0x80010108 (RPC_E_DISCONNECTED))
… System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
… System.Dynamic.ComRuntimeHelpers.GetITypeInfoFromIDispatch(IDispatch dispatch, Boolean throwIfMissingExpectedTypeInfo)
… System.Dynamic.IDispatchComObject.EnsureScanDefinedMethods()
… CallSite.Target(Closure , CallSite , ComObject , Int32 , Int32 , Int32 , Boolean )
… CallSite.Target(Closure , CallSite , Object , Int32 , Int32 , Int32 , Boolean )
… PrintNotesUIDocumentCOM_version_14_12_2015.PrintNotesDocument_version_14_12_2015.PrintFaxDocument_version_14_12_2015(String serverName, String baseName, String UNID)
COMException.Data = System.Collections.ListDictionaryInternal
this is the code of the dll ,may be it help: /* Creat the notes session's object */
System.Type typeNotes = System.Type.GetTypeFromProgID("Notes.NotesSession", "localhost", true);
dynamic oleSession = System.Activator.CreateInstance(typeNotes);
/* Creat the notes dataBase's object */
dynamic oleDb = oleSession.GetDatabase(serverName, baseName);
/*Creat the notes NotesUIWorkspace's object */
System.Type typeNotesUI = System.Type.GetTypeFromProgID("Notes.NotesUIWorkspace", "localhost", true);
dynamic oleWK = System.Activator.CreateInstance(typeNotesUI);
/* Open the notes dataBase's */
dynamic objDbUi = oleWK.OpenDatabase(serverName, baseName);
dynamic oleDoc = oleDb.GetDocumentByUNID(UNID);
Thread.Sleep(500);
/* opens the document having universal ID given as an argument in the view in Edit mode.
EDITDOCUMENT Return a notesUIDocument :oleUIDoc */
dynamic oleUIDoc = null;
if (oleDoc != null)
{
Console.WriteLine("/C#\\ befor editdocument ");
oleUIDoc = oleWK.EDITDOCUMENT(false, oleDoc, false,"",true,false);
Console.WriteLine("/C#\\ after editdocument ");
}
else
{
Console.WriteLine("/C#\\ oledoc = null ");
}
/* Print the curent Notes Document previously set */
dynamic x = oleUIDoc.Print(0, 0, 0, false);
oleUIDoc.close();
/* Close the previously open notes dataBase */
dynamic oleUIDB = oleWK.CurrentDatabase();
oleUIDB.close();
oleDoc = null;
oleUIDoc = null;
oleWK = null;
oleDb = null;
oleUIDB = null;
oleSession = null;