Monday, August 29, 2016

(Solved) Error: Server.CreateObject Failed - Classic ASP in IIS

Error:
Server object error 'ASP 0177 : 800401f3' Server.CreateObject Failed

C:\INETPUB\WWWROOT\TestApp\AUTHENTICATION\../serverlib/global.asp, line 190

800401f3

Solution with Sample code:

  • Open the error file and go to the corresponding line (here 190)

if (!sleep.waiter) sleep.waiter = Server.CreateObject("WaitFor.Comp"); // error line
sleep.waiter.WaitForSeconds(sleepSeconds);

  • Get the Waitfor component file location.
  • Run command prompt as Administrator.
  • Execute the below command 

  1. C:\Windows\system32> regsvr32 "C:\inetpub\wwwroot\TestApp\serverlib\components\WaitFor\waitfor.dll"

Note: WaitFor is a component used here.

Wednesday, August 24, 2016

Convert Excel file Stream to DataTable in C# .NET

Using ExcelDataReader library we can convert a file stream excel file to a DataTable. The excel file no need to be saved to the local drive. The sample code is given below.

  1. byte[] buffer = Convert.FromBase64String(fileData.Replace(' ', '+'));
  2.  
  3. Stream stream = new MemoryStream(buffer);
  4.  
  5. var result = this.ExcelStreamToDataSet(stream);
  1. public DataSet ExcelStreamToDataSet(Stream stream)
  2. {
  3. IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
  4.  
  5. excelReader.IsFirstRowAsColumnNames = true;
  6.  
  7. var ds = excelReader.AsDataSet();
  8.  
  9. excelReader.Close();
  10.  
  11. return ds;
  12. }