Friday, June 22, 2012

Terminate Process that encounters an error

Simply set the error data received and terminate the process.
Code:
      private void button2_Click(object sender, EventArgs e)  
      {  
        foreach (Process p in Process.GetProcesses())  
        {  
          p.ErrorDataReceived += new DataReceivedEventHandler  
            (p_ErrorDataReceived);  
        }  
      }  

      void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)  
      {  
        Process p = (Process)sender;  
        p.Kill();  
     } 

Friday, June 8, 2012

Webbrowser Control has different Document Text on different computers.

We encountered a problem where in a web crawler doesn't run on a remote server, but run perfectly on a local machine. The crawler utilizes the web browser control from microsoft.

The problem turns out that the local machine's IE browser is version 9 and the remote server has IE 8.
The solution was to re deploy the exe file to another remote server that has IE 9.

Cheers!

Wednesday, June 6, 2012

How to align text a merged cell in excel using C#

Code:
1:  chartRange.Merge(Type.Missing);  
2:  chartRange.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;

Source: sanket's blog

Monday, June 4, 2012

Object does not contain a definition for get_Range (MS Excel)

Here's the original snippet that shows the error:
Code:
chartRange = sheet.get_Range(sheet.Cells[row_indicator, column_indicator],  
sheet.Cells[row_indicator, column_indicator + 11]);
Modified snippet:
Code:
 chartRange = sheet.get_Range((object)sheet.Cells[row_indicator, column_indicator],  
 (object)sheet.Cells[row_indicator, column_indicator + 11]); 
Just cast the cells with object.

Cheers!

Saturday, June 2, 2012

Error 3417 (SQL Server 2008) unable to start service..

Yesterday,

My sql server 2008i stopped working due to error 3417. I tried different solutions as provided by msdn forums and other sites such as compression attributes, network service to be added on security and change log-on to local system and restoring my master db using cmd. All did'nt work.

I ended up backing up all my databases, uninstalling the database service but retaining the other features such as business intelligence studio, IDE tools and etc. Then, re installing the database services w/ same credentials as before.

Greg