2013-03-16 39 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>());