为水晶报表创建SessionMgr实例会抛出错误

本文关键字:出错 错误 实例 SessionMgr 水晶 报表 创建 | 更新日期: 2023-09-27 18:15:33

我使用下面的代码连接到SAP cms服务器,从它获得报告。

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
        }
    }

但是我得到下面提到的错误,同时执行以下代码行:SessionMgr session_mgr = new SessionMgr();

类型的未处理异常"System.Runtime.InteropServices。COMException'发生在CrystalDecisions.Enterprise.Framework.dll

附加信息:为组件检索COM类工厂使用CLSID {6670DE06-3F39-4C5D-9238-71FF984D2654}失败80040154类未注册(来自HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG) .

为水晶报表创建SessionMgr实例会抛出错误

根据nobugz在这里的回答
https://social.msdn.microsoft.com/forums/vstudio/en - us/88a6ea68 f476 - 4231 - 822 - f - 27 - fabe59f458/error - 80040154 -检索- com -类- factory?forum=vbgeneral
建议您检查HKCR'CLSID中的键值以获取GUID。如果不在那里,它可能在另一个文件夹(c:'windows'system32…)。另一种方法是用Regmon调试。
"它向你展示了你的应用是如何使用注册表的。

尝试:

ISessionMgr sessionMgr = CrystalEnterprise.GetSessionMgr();
IEnterpriseSession enterpriseSession = sessionMgr.Logon("userName", "password", "cmsName", "secEnterprise");
string token = enterpriseSession.LogonTokenMgr.DefaultToken;
相关文章: