2012-11-02 65 views
0

我正在使用Visual Studio 2010以及安装的各种必需插件与SAP Crystal Server 2011进行通信。一切正常,我可以查询数据(例如,返回文件夹列表在一个文件夹中)没有问题。Crystal Server .NET集成企业ReportDocument.Load异常

我试图将这与CrystalReportViewer组件集成,这似乎是工作,直到我试图加载返回的InfoObject到ReportDocument.Load。它始终返回:

未知错误0x80040200。

任何想法将不胜感激。我有点不知所措。关于如何做到这一点的其他建议我也会参加。

只是为了澄清。登录工作正常,InfoObject有效(Response.Write返回报告的正确ID和标题)。

SessionMgr ceSessionMgr = new SessionMgr(); 
EnterpriseSession ceSession = ceSessionMgr.Logon(ConfigurationManager.AppSettings["CrystalUser"].ToString(), ConfigurationManager.AppSettings["CrystalPassword"].ToString(), ConfigurationManager.AppSettings["CrystalServer"].ToString(), "Enterprise"); 
EnterpriseService ceEnterpriseService = ceSession.GetService("", "InfoStore"); 
InfoStore ceInfoStore = new InfoStore(ceEnterpriseService); 

PluginManager cePluginMgr = ceInfoStore.PluginManager; 
PluginInfo ceReportPlugin = cePluginMgr.GetPlugins("Desktop")["CrystalEnterprise.Report"]; 

InfoObjects ceInfoObjects = ceInfoStore.Query("SELECT * FROM CI_INFOOBJECTS WHERE SI_PROGID='CrystalEnterprise.Report' AND SI_ID=" + Convert.ToInt32(Request["ReportID"])); 

InfoObject ceInfoObject = ceInfoObjects[1]; 

Response.Write(ceInfoObject.ID.ToString() + " = " + ceInfoObject.Title + "<br/>"); 

CrystalDecisions.CrystalReports.Engine.ReportDocument ceReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); 
ceReportDocument.Load(ceInfoObject, ceSession); 

CrystalReportViewer1.Visible = true; 
CrystalReportViewer1.EnterpriseLogon = ceSession; 
CrystalReportViewer1.ReportSource = ceReportDocument; 

回答

1

不得不通过使用RAS服务器来解决此问题。不知道为什么上述不起作用,因为根据Docs它应该。

// View the report using page server 
PSReportFactory yPSReportFactory = (PSReportFactory)ceSession.GetService("PSReportFactory").Interface; 
myReportSource = myPSReportFactory.OpenReportSource(ReportID); 
//place the report source in session for use with postbacks 
Session.Add("ReportSource", myReportSource); 

CrystalReportViewer1.EnterpriseLogon = ceSession; 
CrystalReportViewer1.ReportSource = myReportSource;