2013-03-16 78 views
0

我保存报告模板加载:Stimul报告:的BusinessObjects不被显示报告

report.Save("C:\\kk.mrt"); 

然后我打开保存的报告,并指定其为BusinessObjectsDictionaries

StiReport rptLoad = new StiReport(); 
rptLoad.RegBusinessObject("Company", repository.GetAll<Company>()); 
rptLoad.Load("C:\\kk.mrt"); 

rptLoad.BusinessObjectsStore包含注册BusinessObjects刚刚注册(WatchedRunTime),但:

rptLoad.Show(); 
  • 如果有Bindings(像:Components.Add(new StiText{Text="{Company.Name}"})包含在保存的报告:THEN

    打动了我:error CS0103: The name 'Company' does not exist in the current context

  • 否则,如果我没有Bindings在保存的报告:THEN

    rptLoad.Show();将显示报告,但没有注册Dictionaries(当我在显示报告后进入设计模式时,我看不到BusinessObjects字典)。

  • ,如果我叫rptLoad.Design();rptLoad.Show();:THEN

报告显示和Bindings都OK,我可以在所示报告(在设计和预览模式)看到BusinessObjects

回答

1

找到了症结:

  rptLoad.Dictionary.Synchronize(); 

应该叫后rptLoad.RegBusinessObject("Company", repository.GetAll<Company>());