The Silverlight Viewer doesn’t show images. Why does this happen to me?

Let’s imaging that you’ve opened your report and instead of expected logo image of your favorite Silverlight Viewer in the left top corner of your report you see nothing... only a red cross. The same situation is with the chart in the center of your report. The worst day in your life... But wait, we still can see the text labels. These signs may suggest some thoughts.

Let’s think...

  1. The issue may be related with wrong web.config settings.
    • The "rest" endpoint should be configured properly.
      For example:
      <endpointBehaviors>
          <behavior name="webBehavior">
              <webHttp />
          </behavior>
      </endpointBehaviors>
      
      <services>
          <service behaviorConfiguration="SampleApplicationSL4.
      Web.ReportServiceBehavior" name="SampleApplicationSL4.Web.
      ReportService">
              <endpoint address="rest" binding="webHttpBinding"
      contract="PerpetuumSoft.ReportingServices.Viewer.Server.
      IReportServiceResources"
      behaviorConfiguration="webBehavior" 
      bindingConfiguration="webHttpBindingConf" />
          </service>
      </services>
      
      <bindings>
          <webHttpBinding>
              <binding name="webHttpBindingConf">
                <security mode="None" />
              </binding>
          </webHttpBinding>
      </bindings>

      The following setting isn't correct:

      <endpointBehaviors>
          <behavior name="webBehavior">
              <!-- no settings here -->
          </behavior>
      </endpointBehaviors>
    • The service name should correspond the type name of the "PerpetuumSoftServices" section.
      For example:
      <PerpetuumSoftServices>
          <Service Type="SampleApplicationSL4.Web.ReportService, 
      SampleApplicationSL4.Web">
          </Service>
      </PerpetuumSoftServices>
      
      <services>
          <service behaviorConfiguration="SampleApplicationSL4.
      Web.ReportServiceBehavior" name="SampleApplicationSL4.Web.
      ReportService">
          </service>
      </services>

      The following setting isn't correct:

      <services>
          <service behaviorConfiguration="SampleApplicationSL4.Web.
      ReportService2Behavior" name="SampleApplicationSL4.Web.
      ReportService2">
          </service>
      </services>
    Depending on other configuration settings the application may work but requests to the images will fail.
  2. If the ReportService is located on the other server, you need to set the address of the server in the web.config file in the PerpetuumSoftServices section:
    <ReportServiceResourcesURL 
    value="http://localhost:5555/ReportService.svc"/>
    Here is a code fragment which demonstrates how it looks in your Web.Config:  
    1. <PerpetuumSoftServices>  
    2.   <LogMode value="On" />  
    3.     <Service Type="SL4.Web.ReportService, SL4.Web">
    4.     <MsReportingServer Url="http://localhost/ReportServer/ReportExecution2005.asmx" Timeout="2147483647" >   
    5.       <Credentials Domain="" UserName="" Password="" />  
    6.    </MsReportingServer>  
    7.   </Service>  
    8.   <ReportServiceResourcesURL value="http://localhost:5555/ReportService.svc"></ReportServiceResourcesURL>  
    9. </PerpetuumSoftServices>  
  3. The problem may also be related with cache mechanism on WCF service. In order to change cache mechanism, you need to override the CreateCache() function so that it returns the class which implements the IReportCache interface. The code example of the class that implements the cache.
      internal class AspNetCache : IReportCache
      {
        #region IReportCache Members
     
        public virtual void AddDocumentToCache(string key, 
    object value, params object[] parameters)
        {
          HttpContext.Current.Cache.Add(key, value, null, 
    DateTime.MaxValue, new TimeSpan(1, 0, 0), 
    CacheItemPriority.Default, null);
        }
     
        public virtual object GetDocumentFromCache(string key)
        {
          return HttpContext.Current.Cache.Get(key);
        }
     
        public virtual void AddPageToCache(string key, PageInfo value, 
    params object[] parameters)
        {
          var dep = new CacheDependency(null, new[] 
    { value.DocumentId });
          HttpContext.Current.Cache.Add(key, value, dep, 
    DateTime.MaxValue, new TimeSpan(0, 60, 0), 
    CacheItemPriority.Default, null);
        }
     
        public virtual object GetPageFromCache(string key)
        {
          return HttpContext.Current.Cache.Get(key);
        }
     
        public void AddExecutionToCache(string executionId, 
    object executionCacheObject)
        {
          HttpContext.Current.Cache.Add(executionId, 
    executionCacheObject, null, DateTime.MaxValue, 
    new TimeSpan(1, 0, 0),  CacheItemPriority.Default, null);
        }
     
        public object GetExecutionFromCache(string executionId)
        {
          return HttpContext.Current.Cache.Get(executionId);
        }
     
        #endregion
      }

    The code of the ReportService will be as follows:

    [AspNetCompatibilityRequirements(RequirementsMode = 
    AspNetCompatibilityRequirementsMode.Required)]
    public class ReportService : ReportServiceRemote
    {
      protected override IReportCache CreateCache()
      {
        return new AspNetCache();
      }
    }
    An example with cache additions: SampleApplicationSL4_Cache.zip.
    Note at AspNetCache.cs and SessionCache.cs files.

Add Feedback