Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my window service when I run window service from manage ,ScheduledService.txt file does not contain "Get Connection". I think there is problem in GetConnectionOfReportServer, it may it take more time.
When I debug it is working fine.
I debug the code problem is in "this.reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote" in GetConnectionOfReportServer(),after this line control does not go ahead.

My code is
C#
  protected override void OnStart(string[] args)
        {
            TraceService("start service");
            timer = new System.Timers.Timer(1000);
            timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
            timer.Interval = 90000;
            timer.Enabled = true;
  
        }
 protected override void OnStop()
        {
            TraceService("stopping service");
        }

 private void OnElapsedTime(object source, ElapsedEventArgs e)
        {
           
           time_elapsed();
            TraceService("Another entry at " + DateTime.Now);
        
        }
  private void time_elapsed()
        {           
            TraceService("Call susseccfully");
            GetConnectionOfReportServer();
            TraceService("Get Connection");
            DailyReportFile = getReportFrmServer(reportName, param);
        }
    public void GetConnectionOfReportServer()
        {
 TraceService("I am in GetConnectionOfReportServer.");
            try
            {
 TraceService("I am in Try.");
                NetworkCredential credential = new NetworkCredential("administrator", "epass@123");
                this.reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = credential;
TraceService("I am in Try end");
                this.reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;  // this line is not working
    TraceService("I am in Try ProcessingMode.Remote");
                this.reportViewer1.ServerReport.ReportServerUrl = new Uri(@"http://xxx.xxx.xxx.xxx/ReportServer");
TraceService("I am in Try end");

            }
            catch (Exception ex)
            {

            }
        }
 private void TraceService(string content)
        {
            FileStream fs = new FileStream(@"c:\ScheduledService.txt", FileMode.OpenOrCreate, FileAccess.Write);

            StreamWriter sw = new StreamWriter(fs);
            sw.BaseStream.Seek(0, SeekOrigin.End);
            sw.WriteLine(content);
            sw.Flush();
            sw.Close();
        }


In ScheduledService.txt file
start service
Call susseccfully
I am in GetConnectionOfReportServer.
I am in Try.
I am in Try end
Call susseccfully
I am in GetConnectionOfReportServer.
I am in Try.
I am in Try end
Posted
Updated 18-Jul-13 19:43pm
v3
Comments
[no name] 18-Jul-13 6:17am    
You need to log your exceptions also instead of ignoring them.
Bernhard Hiller 18-Jul-13 8:26am    
ScheduledService file does not contain "Get Connection" - what do you want to tell us? Could you give use the error message exactly as it was written to your log files / event log (in the latter case, you the event viewer)?
Member 7909353 19-Jul-13 0:50am    
I debug the code problem is in "this.reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote" in GetConnectionOfReportServer(),after this line control does not go ahead.
[no name] 19-Jul-13 6:47am    
You would need to tell us what "this line is not working" means... And you still need to log exceptions instead of ignoring them. Pretty valuable debugging information that you are just throwing away.... still.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900