You are viewing limited content. For full access, please sign in.

Question

Question

Unable to cast COM object of type 'System.__ComObject' to interface type 'LFSO80Lib.LFDocument'.

SDK
asked on January 24, 2019

Hellow,

I am beginner in ASP.Net and am working with Laserfiche SDK, But when trying to access the LFDocument Object I get the following Error.

 

Unable to cast COM object of type 'System.__ComObject' to interface type 'LFSO80Lib.LFDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{E1828B6A-D73E-4AD8-A3E1-EE3CA060D194}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

event viewer does not show anything regarding this error. If I dont use that Object everything works fine but I need to get the documents so I must use that.

 

here is my sample code

using System;
using System.Configuration;
using System.Data;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using LFSO80Lib;


public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        lbtest.Text = "";
        LFSO80Lib.LFApplication app = new LFSO80Lib.LFApplication();
        LFSO80Lib.LFServer serv = (LFSO80Lib.LFServer)app.GetServerByName("host NAME");
        LFSO80Lib.LFDatabase db = (LFSO80Lib.LFDatabase)serv.GetDatabaseByName("REPOSITORY NAME");
        LFSO80Lib.LFConnection conn = new LFSO80Lib.LFConnection();
        conn.UserName = "USERNAME"; 
        conn.Password = "PASSWORD"; 
        conn.Create(db);

        

        int id = Int32.Parse(Request.QueryString["ID"]);
       

        LFDocument doc = (LFDocument)db.GetEntryByID(id);
        LFSO80Lib.LFDocumentPages docpages = (LFSO80Lib.LFDocumentPages)doc.Pages;
        docpages.MarkPageByIndex(1);
        DocumentProcessor80.DocumentExporter exporter = new DocumentProcessor80.DocumentExporter();
        exporter.AddSourcePages(docpages);
        exporter.Format = DocumentProcessor80.Document_Format.DOCUMENT_FORMAT_PNG;


        byte[] imageStream = null; 
        imageStream = (byte[])exporter.Export();
        doc.Dispose();
        conn.Terminate(); 
        Response.ContentType = "image/jpeg";
        Response.BinaryWrite(imageStream);
        Response.End();
     
       

    }
    
}

Any help please..

error.PNG
error.PNG (75.1 KB)
0 0

Answer

SELECTED ANSWER
replied on January 24, 2019

You may want to first get it as an ILFEntry and check the entry type.  If entry type = document, get it as an LFDocument object.

1 0
replied on January 24, 2019

Thanks this solved the issue.. Though I got another error regarding DocumentProcessor Library.. Seems like there are unregistered class but am not sure about it.. Help plz..

0 0

Replies

replied on January 24, 2019

Bert is probably right about the root cause.  If this is a new project you would be better off using the .Net SDK instead of the COM one.  One benefit is better error messages, which in this situation would be something like "Can't cast instance of FolderInfo to type DocumentInfo".

1 0
replied on January 24, 2019

It is not new project.. But we will consider changing it.. This was working on the other server but after migrating to other servers it started misbehaving..

0 0
replied on January 24, 2019 Show version history

Try installing the LF SDK Runtime on the new server.

Also make sure your references to the LFSO and DocumentProcessor are set correctly

0 0
replied on January 24, 2019

Brian is correct that the .NET SDK is a much better way to go. We built a custom API using the .NET SDK, I feel it is more robust and the error messages are much more descriptive.

 

On a separate note... I see you copied my profile image lol.

0 0
replied on January 24, 2019

Sure I liked it n it was long time ago.. If you dont mind May I keep it..!??

0 0
replied on January 24, 2019

I don't mind.

I still have the file I used to create it if you'd like a version with a slightly different background color or anything like that.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.