Recent Posts

Tuesday, September 15, 2015

How to implement logging in database table and log file using NLog in C#

NLog is a .Net Library which is very useful for logging program information. It delivers various features of logging error free. NLog allows users to write the logs to various outputs some of most helpful are: a File text console email message database event log and many more For full article please follow my personal blog post "How to implement logging in database table and log file using NLog in C# "

Read more!

Tuesday, August 18, 2015

Cannot implicitly convert type 'Google.Apis.Drive.v2.Data.File' to 'System.IO.File' - Resolved Code

I was using Google Drive API go get File Name of the stored file in Google drive

Although following the sample code provided by Google I encountered following error:

Cannot implicitly convert type 'Google.Apis.Drive.v2.Data.File' to 'System.IO.File'. I was surprised to find there were not much written about this.

I thought it would be a small but helpful post to some. Instead of wasting  precious time you can just do following to resolve this issue:

  1. If you are using System.IO in your program, then it will first pickup System.IO.File and ignore the Google.Apis.Drive.v2.Data.File.
  2. Therefore to resolve this issue you need to give full path of the Google Drive File
  • For Eg:
        Google.Apis.Drive.v2.Data.File file = service.Files.Get(fileId).Execute();
            Console.WriteLine("Title: " + file.Title);
              Console.WriteLine("Description: " + file.Description);
                Console.WriteLine("MIME type: " + file.MimeType);

        Hope this helps, Enjoy coding guys........

        Read more!

        Sunday, August 2, 2015

        XAMPP Error - Apache shutdown unexpectedly - This may be due to a blocked port (Solved)

        I was having the problem restarting Apache using XAMPP in Windows 7. Every-time I start Apache there was an error popping up. I had a solution to change the port to 8080 but that was not what i was looking for i was looking for solution that should work without changing anything in the config and work as normal.

        Following was the error appearing in my XAMPP:
        Error: Apache shutdown unexpectedly.
        8:33:18 PM  [Apache] This may be due to a blocked port, missing dependencies, 
        8:33:18 PM  [Apache] improper privileges, a crash, or a shutdown by another method.
        8:33:18 PM  [Apache] Press the Logs button to view error logs and check
        8:33:18 PM  [Apache] the Windows Event Viewer for more clues
        8:33:18 PM  [Apache] If you need more help, copy and post this
        8:33:18 PM  [Apache] entire log window on the forums
        So I was looking for the solution all over the place and finally i figured it out.

        1.  Figure out what applications are using port 80 and if there are not crucial applications that are using port 80 then you can free the port for XAMPP to use it. 
          • First open cmd as Administrator -- do this by typing cmd in search bar and right click cmd.exe and run as Administrator
          • Enter netstat -aon | findstr :80 to find all the necessary applications that are using port 80.
        2. Now to free up the port 80 type in : net stop http 
        3. It will ask permission to stop the applications that are using up port 80, Just type Yes 
        4. Now run Apache in XAMPP -- this should solve the problem and now Apache is up and running...
        Important: Skype uses port 80 by default, you can change this in skype options > advanced > connection - and uncheck "use port 80"


        Read more!

        Tuesday, July 28, 2015

        Cannot start apache from xampp on windows 7 due to ports blocked (fixed)

        In my Windows 7 i had installed .net and so IIS was running and therefore it was normally using up the port 80 and therefore any other trying to work on port 80 was rejected.
        I had this issue while I tried to restart Apache server from xampp it was always giving error saying access to the port was denied.

        To avoid this issue I had to search the web every time i open up xampp. To fix this problem i have decided to write up this blog post that covers the solution of the issue:

        Problems running XAMPP while running IIS. If you are running IIS it might be worth stopping the service then starting XAMPP.

        If you just want to make Apache run an don't mind which port it is running on, do the following:

        1. In the XAMPP Control Panel, click on the Apache - 'Config' button which is located next to the 'Logs' button.

        2. Select 'Apache (httpd.conf)' from the drop down. (notepad should open)

        3. Do Ctrl + F to find '80'. Click 'find next' three times and change line Listen 80 to Listen 8080

        4. Click 'find next' again a couple times until you see line ServerName localhost:80 change this 
        to ServerName localhost:8080

        5. Do Ctrl + S to save and then exit notepad.

        6. Start up Apache again in the XAMPP Control Panel, Apache should successfully run.

        7. Use http://localhost:8080/ in your browser address bar to check everything is working.

        Thanks to Afroman in the stackoverflow comment :

        Read more!

        Friday, July 24, 2015

        How to use multiple Kendo UI Grid MVC in single view page that has export facility using free version

        Kendo UI for MVC is paid version and since i was exploring the free version of the Kendo UI grid in MVC. I figured out this code that grabs data from the controller and displays multiple grid in the view and can export data from both the grids to excel with desired file name.

        To do this I am not going to show how you are going to grab the data from the database but i will only display the controller code and the view code...
        ... 1. First of all include the .js and .css file in _Layout.cshtml page
        2. Controller code
                1. First thing is to reference DocumentFormat.OpenXml.Packaging you can install it via NuGet Packages (right click on your solution and select Manage NuGet Packages and search for DocumentFomat.OpenXML and install it.

        2. Next thing to note is you must return the view else if you just return the data then it will only display json result on the screen

                 3. Return json result for the data for two grids I have GetCars and GetOtherCars here in my code
               4. Now insert the code to render the excel file (full code is found in the full working project attached at the bottom of this blog post)
               5. Now in the View (Index.cshtml) insert two grids where you should note is disable odata and mention excel export (full code is found in the full working project attached at the bottom of this blog post)
                                   //  type: "odata",

        Download Full Source code to display multiple Kendo UI MVC Grid in same View page using free version of Kendo UI

        Read more!

        Loading bar is not displayed in kendo UI grid while not setting default height

        When i removed the default height of Kendo UI Grid to "Increase the height of kendo UI grid to full page to display all records of grid" I faced another problem.

        The loading image in Kendo UI grid was not displaying and the grid initially collapsed. This created the impression that the Kendo UI Grid was not loading at all so there was a great chance that users were distracted from the page.

        To fix this issue I figured out just place one css code mentioned below that sets the min height of the grid so the Kendo UI grid displays the loading bar and after the data is loaded everything is all good..

        Css Code to set min height of the Kendo Ui Grid is as follows:
          .k-grid-content {
                /*For setting min height to see the loader so that user are not distracted if the grid is loading or not*/
            min-height: 200px;

        Read more!

        Increase the height of kendo UI grid to full page to display all records of grid

        First of Kendo UI grid is set to fixed height and when you have enabled paging then say it will show 5,10,15 or All records when selecting on the drop down list.

        When we select the number from the list and the records are more than the height of the grid then the records move inside the scroll bar which was not my option for the grid.

        I wanted to display all the records without the scroll bar appearing and expand the grid to show all the records selected without the scroll bar. Say if i select "All" then the grid should expand vertically to full length of the page.

        To achieve this you must do following for your grid
        1. Remove the height of the grid
           _grid = $("#grid").kendoExcelGrid({
                       // height: $(document).height()-100,
        2. Since the grid should expand and contract based on the number of rows we don't need vertical scroll bar to do this use the following css:
        #grid .k-grid-header
              padding: 0 !important;

            #grid .k-grid-content
                /*don't show the disabled scollbar at the right to make grid look clean*/
                overflow-y: visible;
        Now you are able to expand Kendo UI grid vertically when you select all records

        Read more!

        Thursday, July 23, 2015

        How to Find the Wi-Fi Password of your Current Network

        Sometimes you forget your own wi-fi password when it has been setup for very long time in the past and it would be very uncomfortable if someone asks for password to connect to their mobile and you say "mmm I don't remember".

        I have forgotten wi-fi password for many time and this situation has come to me many times.

        Now i luckily found out the blog by Amit Agrawal (thanks to him) that has solved this problem.

        To Find the Wi-Fi password on windows do following 

        1. Go to Start and type cmd on search and when cmd.exe appears right click and click Run as Administrator
        2. Type the following text: netsh wlan show profile name=myWLan key=clear
        3. Then press Enter and you will see your password in the field called Key Content

        ( "myWLan" is the Wi-Fi network you are connected in)

        For more.. and lean how to retrieve wi-fi password in MAC please refer to Amit's Blog in following link:

        Read more!