Creating SessionMgr instance for crystal reports throws error

0

I am using below code to connect to a SAP cms server to get the reports from it.

using CrystalDecisions.Enterprise;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string username = "user";
            string password = "pwd";
            string server = "srv_name";
            string auth_type = "authType";
            // logon
            SessionMgr session_mgr = new SessionMgr();
            EnterpriseSession boEnterpriseSession = session_mgr.Logon(username , password, server, auth_type);

            //boInfoStore = (IInfoStore)boEnterpriseSession.getService("InfoStore");

            //boInfoStore = (IInfoStore)boEnterpriseSession.GetService("InfoStore");

            // get the serialized session
            //string session_str = session.SerializedSession;
            // pass the session to our custom bypass page on the CRS

        }
    }

But I am getting below mentioned error while executing following line of code : SessionMgr session_mgr = new SessionMgr();

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in CrystalDecisions.Enterprise.Framework.dll

Additional information: Retrieving the COM class factory for component with CLSID {6670DE06-3F39-4C5D-9238-71FF984D2654} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

c#
crystal-reports
asked on Stack Overflow Oct 31, 2016 by Relativity

2 Answers

0

According to nobugz's answer here
https://social.msdn.microsoft.com/Forums/vstudio/en-US/88a6ea68-f476-4231-822f-27fabe59f458/error-80040154-retreiving-com-class-factory?forum=vbgeneral
It is suggested that you check the keys in HKCR\CLSID for the GUID. if it is not in there, It may be in another folder(c:\windows\system32...). The another way is to debug with Regmon.
"It shows you how your app uses the registry. Run it on yours and run it on the customer's and compare the two".

answered on Stack Overflow Oct 31, 2016 by FreeMan
0

Try:

ISessionMgr sessionMgr = CrystalEnterprise.GetSessionMgr();

IEnterpriseSession enterpriseSession = sessionMgr.Logon("userName", "password", "cmsName", "secEnterprise");

string token = enterpriseSession.LogonTokenMgr.DefaultToken;
answered on Stack Overflow Feb 27, 2019 by craig

User contributions licensed under CC BY-SA 3.0