Thursday, 23 December 2010

Sign in & Access Multiple Google / Gmail Accounts at Once from the same Browser

Google introduced a new feature which lets you sign in and access two  different Gmail / Google accounts at once on the same browser.  Most of us have more than one email Id which we use for different purposes. Previously , one can login to only one account at a time through one browser. This new feature eliminates the need of signing out or using a different browser for using other account. Here is the procedure to use multiple accounts in the same browser at the same time..
  • Go to google.com/accounts
  • Navigate to Multiple sign-in option – “Use multiple Google Accounts in the same web browse” and turn it on.
  • Sign into your first account.
  • After that, you can sign in with up to two additional accounts using the new accounts menu.
After enabling it, You can open  and use multiple Gmail / Google accounts in different tabs of the same browser. The feature can also be disabled by going to the above path and turning it off.
Although the multiple account sign-in feature is available for users, it doesn’t support all Google services like like Blogger and Picasa Web Albums, etc. For these services, the default account will be the first account you signed into. As of now, This feature is supported App Engine, Code, Calendar, Gmail, Reader, Sites and Voice and is restricted to desktop broswers and cannot be enabled on your mobile phones.

Firefox 4 Beta 1 Review

Firefox 4 Beta 1 was released . The newer version of Firefox from Mozilla is definitely better than Firefox 3.6 and is definitely worth trying out. Firefox 4 runs on the Gecko 2.0 web platform. Earlier today I downloaded Firefox 4 and put it through some drills, here is a review of Firefox 4 Beta 1 where you can find the new features and also the how Firefox 4 fares against other browsers in web browser benchmarks.

New User Interface

Firefox 4 New User Interface
Firefox 4 sports a completely different interface, some of which are from Opera and Google Chrome. Firefox 4 has some new buttons and also a unified menu which is similar to the one Opera 10.6 has. In addition to that the tabs also default to the top which is similar to Google Chrome.
However, the menu bar is initially hidden and users can unhide it to go back to the older navigation found in Firefox 3.6 and below.
Firefox 4 Bookmarks menu
Firefox 4 also has a new bookmark button giving users easy access to their bookmarks with one click. You can find and navigate through all your bookmarks and folders using the bookmark button next to the search box.

New Add-ons Manager

firefox_4_addons_manager
Firefox 4 sports a new add-ons manager which integrates into the browser. However, the interface is still under construction and you cannot use the add-ons manager to browse and install add-ons yet. However, it is definitely much better than the earlier version and also has some new developer tools.
Mozilla also says that the add-ons manager UI will be changed before the final release, so don’t start falling in love with it yet.

Search and Switch to Open Tabs

firefox_4_switch_to_tab
Firefox 4 also has a hidden gem in the smart location bar, which will allow you to switch to an open URL by typing in the URL or searching for the title of the page. The feature is very handy if you have several open tabs and want to switch to it without navigating through all the tabs.
When you want to switch to an open tab, just start typing the URL or the title of the page and you will be shown an option to Switch to that open tab. Pretty neat.

Windows 7 Integration

firefox_4_windows_7_integration firefox_4_windows_7_jumplists
Firefox 4 tightly integrates into Windows 7 by having tab previews and Jumplists. Using the tab previews you can easily preview all open tabs. In addition to that the jumplists allows you to quickly perform tasks and open frequently opened URLs.

Native HTML5 WebM Videos Support

firefox_4_html5_video
Firefox 4 has native support for HTML5 WebM videos. WebM is an open source royalty free codec for HTML5 videos which is an alternative to H.264 and Theora codes .  In my tests HTML5 videos works pretty good on YouTube.

Speed and Other Benchmarks

firefox_4_peacekeeper_benchmark
Firefox 4 is definitely much more lighter and faster than Firefox 3.6 and it uses much less memory than the earlier versions. However, Firefox 4 is not yet the fastest browser and it was beaten by both Google Chrome 6 (dev) and Opera 10.60 in the Peacekeeper benchmarks I ran.
firefox_4_acid_3
Firefox also failed the Acid 3 test, but the results were far better than Firefox 3.6. This shows a lot of improvements being done under the hood. Firefox 4 was also slower than in the SunSpider JavaScript Benchmark  and way too slow in the V8 benchmarks I ran (screenshots coming shortly).

Other Features

Firefox 4 also has Crash protection for Flash, QuickTime and other plugins, however, this was introduced in Firefox 3.6. Firefox 4 also has a HTML5 parser which allows you to run the latest apps, support for WebSockets for real-time online interactions like chatting and gaming and IndexedDB which will allow users to use offline storage.

Monday, 13 December 2010

Use of Ctrl + C can Leak Our Personal Information

Well we all know the use of Ctrl + C of any computer. The use of Ctrl + C has a very great disadvantage sometimes which can leak our personal information and ruin our life. I know this long back but when I read the article about Ctrl + C yesterday in the Times of India newspaper, I thought many people may not be aware of this evil use effect of Ctrl + C. So I am sharing the same article with you today.
Everytime you do a harmless keyboard shortcut Ctrl + C in your computer, the text you copy online may be stolen on the web. This copied data is accessible on the internet when you visit websites that use the combination of javascript and ASP or any server-side-language like jsp, php, from which the data that you copy can be transferred to another server. Most web server. Most web sites are javascript enabled.
Not convinced? Try copying some text and just visit sourcecodesworld.com/special/clipboard.asp, a websiteƂ  that provides free source codes and projects. You necessarily need not even press the ‘paste’ button. The ‘paste’ happens automatically. The website just provides an example of what could potentially happen to you, especially if you have copied your credit card details, bank details or any other sensitive information.
“This is one of the main reasons that credit card companies and banks ask you not to copy, paste your card and bank details. Everytime you copy some information, it gets stored in your computer clipboard. In case, you end up visiting a malicious site, your information can be easily stolen. This information can be read in a hidden manner, that you will not be aware of it being seen by someone else”.
Sourcecodesworld.com says this hacking can be done by a simple source code. This happens especially if you are using Internet Explorer. One of the ways it can be avoided is to use a better browser because Internet Explorer, one of the most famous browsers has had many technical glitches over the years.

Wednesday, 1 December 2010

Debugging Silverlight application using Fiddler

Debugging RIA services is not always plain and simple. When you start a new application using RIA services if things are not setup properly you have initial hick-up for debugging the code. If you were using Authentication services then the error will be most common error that login failed without giving any other details. There are lot of blogs out there specifying how to debug this situation, but what I want to mention in this blog is that, use Fiddler when possible to see what is going between the wire.  It works just fine when your web site is hosted and you are monitoring the request and responses from client side.

When it comes to debugging the localhost environment only thing you need to remember is to start the web site as http://localhost./website (emphasis on the ‘.’ at the end of the local host). because of the limitation in fiddler, If you run the normal localhost, it will not monitor. So make sure you use ‘localhost.’ with that you should able to see all the traffic going between client and server.

This link has alternate way of doing it as well.  If you do not want to add ‘.’ at the end of the localhost or the solution in the fiddler web site, then other option is to modify the hosts files (%WINDIR%\System32\drivers\etc\hosts) and then add the following like

127.0.0.1 name

With that change if you would access the web site or the app, instead of calling http://localhost now you can call http://name, fiddler will capture the traffic.

Thursday, 25 November 2010

How to convert Chm files to Pdf ?

How to convert chm files to pdf? So why do we need to convert chm file to pdf? The reason is that chm file actually takes long time to load. For example, if you have a text book in chm file format. It’s around 100MB in size then switching between pages takes a long time and sometimes there might be chance of locking up your system. So how to tackle this problem?


So here comes pdf file. Although there will be reduction in large pdf file and it will be definetly faster then chm file. If we convert chm file to pdf then it might work out and solve our problem. So how to go for it. Well you can visit this website called convert chm to pdf and read the tutorials. It’s very easy. So just convert your chm file into pdf and start reading and what ever you want to do.

Note: - For Linux user, there is a very simple tool called chm2pdf. You give it the file name and it spews out a close to perfect PDF.

If you come across better then the site I referred you then please share with us here. I will update it for my readers. It will be beneficial for all of us.

Saturday, 20 November 2010

Why can’t we Create a Folder by name CON

While browsing through the orkut community, I came across the discussion that folder can’t be name as Con. Then I started googling about Con and got some cool solution to it.
Also read this amazing fact:-
An Indian discovered that nobody can’t create a FOLDER anywhere named as “con“. This is something pretty cool….and unbelievable . At Microsoft the whole Team, including Bill Gates, couldn’t answer why this happened!!!
Source-lists.evolt.org
I am sure that many people still don’t know that they can’t create a Con folder in windows XP and in some other Operating System.
So Why cannot we create a folder by a name Con? What’s the reason behind it?
It’s pretty simple, Con is a reserved name from the early days from DOS, it stands for the “CONSOLE” I/O device, Since it is already used by the system. If we create one with some evil tricks then the system will get confused. There will be an ambiguity.
Check out other reserved words to understand what are all the reserved words using which you can’t create folders in windows.
Like Con, many other reserve words are there which we can’t create. They are
PRN – It stands for printer.
AUX – It stands for Auxiliary device.
COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9 – They stands for serial ports.
LPT1, LPT2, PRN – They stands for Parallel ports.
NUL - It stands for Bid Bucket.
Did I said that the Con folder can’t be created, what a big typo. Well friends, There’s a evil trick to create a Con folder. Here goes the evil tricks.
Open the Command prompt by Start->Run and type in cmd
Type MD\\.\\C:\CON
C is the drive path, you can change this drive to your own choice of path.
Now Open My Computer and browse through the path where you created the Con folder. surprising huh!!! yeah buddy, you have successfully created a Con folder.
Now try to delete the folder, it won’t get deleted by simple delete option. Better try this:-
To delete the folder, type RD\\.C:\CON
Another method to create Con folder without the use of the Dos.
Create a new folder. Name it Con and press Alt + 255 simultaneously.
Well Alt+255 stands for a blank character in ASCII so it allows you to use this folder name.
Note:- Actually you’ll have to press the number’s of the number pad or else it won’t work. That is, create a new folder, rename it Con but don’t press enter yet. Hold down Alt and type 255 on the number pad and then press enter. (for laptop users, press Fn key and press the letter keys k-i-i to make use of number pad).
The next time when someone asks the question that why can’t we create a folder by name Con, say with confidence that it is not true…

Friday, 5 November 2010

My First program using Jounce

This is the first program I wrote to see how much code I need to write and how hard to do simple data binding. Jeremy is doing getting started on Jounce in his blog. What I am doing here is related to his Jounce Part 2.  Here is the final result of the program

image

All this program does is to shows my name in the text box, nothing else. When i started the application I dreaded I will ended up writing lot of code or the process will be complex but to my surprise it is very easy. To make this work, make sure you head down to Code Plex and download the Jounce. We need following three dll from jounce and one from MEF (Which is already part of Framework 4).

Ok Lets start. Fire up VS 2010, create new Silverlight application. Add the above references into the project. Now we are going to add Jounce Framework in the XAML like the following

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             x:Class="simplelabel.App"
             xmlns:Service="clr-namespace:Jounce.Framework.Services;assembly=Jounce.Framework"
             >
    <Application.ApplicationLifetimeObjects>
        <Service:ApplicationService />
    </Application.ApplicationLifetimeObjects>
    <Application.Resources>
    </Application.Resources>
</Application>

xmlns:Service is the reference to Jounce Framework. Next we add the Jounce to silverlight application lifetime object. Ok, lets start coding, lets go to  app.xaml.cs and remove everything except the InitializeComponent, so the code will look like the following

namespace simplelabel
{
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();
        }       
    }
}

Simple huh? What is happenings here is that, since we interjected Jounce to the application life time object, Jounce does all the plumbing for us. Now that we have everything cleaned up in the app side, lets look at the view and view model. I left MainPage.XAML as our view. There is nothing special in here

<Grid x:Name="LayoutRoot" Background="White">
        <sdk:Label Height="28" HorizontalAlignment="Left" Margin="38,32,0,0" Name="label1" VerticalAlignment="Top" Width="47" Content="Name:" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="81,28,0,0" Name="textBox1" VerticalAlignment="Top" Width="235" Text="{Binding Name}" />
    </Grid>

I have one label and one textbox. In the text box, I am binding it to a variable called Name. Which will be discovered by silverlight when running. Lets look at the code behind of mainpage

namespace simplelabel
{
    using Jounce.Core.View;
    using System.ComponentModel.Composition;
    using Jounce.Core.ViewModel;

    [ExportAsView("Shell", IsShell=true)]
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        [Export]
        public ViewModelRoute Binding
        {
            get
            {
                ViewModelRoute route = ViewModelRoute.Create("Shell", "Shell");
                return route;
            }
        }       
    }
}

In this example code, I have one view and viewmodel. Since ‘MainPage’ is my view I need to decorate the view as ‘ExportAsView’ and for view model, decorate it with ‘ExportAsViewModel’. It has name, to bind view and viewmodel, the name must be same. We named the view as ‘Shell’ so make sure the mainpageviewmodel will have the same name as Shell as well. Also since Main page is the start up page for us, add IsShell=true.

Next the most important part, is making sure jounce know which viewmodel belongs to which view, by doing the viewmodel routing. Here we are binding view with name ‘Shell’ (Decorated in attribute ExportAsView) to view model with name ‘Shell’ (will see next). Make sure you decorate the property as [Export] so that jounce finds it.

Time to create view model by creating a class called MainPageViewModel.cs and add the following code

namespace simplelabel
{
    using Jounce.Core.ViewModel;
    using Jounce.Core.View;
    using System.ComponentModel.Composition;

    [ExportAsViewModel("Shell")]
    public class MainPageViewModel:BaseViewModel
    {
        public string Name
        {
            get
            {
                return "Kiran";
            }
        }
    }
}

First thing when we create view model, we make sure we tell Jounce which view it belongs to by decorating it with ‘ExportAsViewModel’ with a name. Next make sure the view model is derived from ‘BaseViewModel’. If you remember in the view, we bound ‘Name’ field to the text block which is coming from this view model. That is it. Now if you run the application, you will the screen shot I showed in the beginning.

I am still learning, long way to go…

Tuesday, 2 November 2010

Jounce – First look

When it comes to Silverlight, one of my favorite blog is none other than Jeremy Likness (Silverlight MVP). I follow his blogs religiously for the simplicity and straight to the point. If you haven’t seen his blog and you are working on Silverlight, make sure you subscribe to his blog.

Couple of weeks ago, in one of his blog he explained he is on to create a new guidance called Jounce for creating silverlight application. I have been looking for a good solution my self was very happy to see the guidance. I downloaded the frame work started playing with it. I really like the frame work. It is very simple, less code and easy to understand. One other reason I like this very much is that, he leverages MEF for most of the application development and MEF is now part of .Net Framework 4.

I am learning how to use Jounce myself thought, I will share my simple examples with you so that we can learn together. In the codeplex, there is excellent documentation and also the download will give you good quick start examples as well.

Wednesday, 13 October 2010

How to create a Simple Windows Service and installer project using .Net

IntroductionAs a matter of fact Microsoft Windows services, formerly known as NT services enable you to create long-running executable applications that run in its own Windows session, which then has the ability to start automatically when the computer boots and also can be manually paused, stopped or even restarted.
This makes services ideal for use on a server or whenever you need long-running functionality that does not interfere with other users who are working on the same computer. You can also run services in the security context of a specific user account that is different from the logged-on user or the default computer account.
Windows services don’t have any interface to the user, so it can not be debugged like any regular application, but it’s debugged as a process. .NET has a very nice tool that enables processes debugging while it’s in the run status, by easily pressing Ctrl + Alt + P shortcut.

Background

I’ve searched well so many sites about a code that I can with the help of it, build a simple Windows service, but I found a lot of code on how to manage the current Windows services of the system and that’s through the ServiceController class.
After searching the MSDN, I’ve found some nice code that helped me to create this simple Windows service. Hope it can help as a basic architecture for and usage of such a Windows service.

Using the code

At first you should simply open VS.NET and then at the File menu click on New, Project. From the New Project Dialog Box, choose the Windows service template project and name it MyNewService like shown below:
Winows Service New Project
The project template automatically adds a component class that is called Service1 by default and inherits from System.ServiceProcess.ServiceBase.
Click the designer. Then, in the Properties window, set the ServiceName property for Service1 to MyNewService.
Set the Name property to MyNewService. Set the AutoLog property to true.
In the code editor, edit the Main method to create an instance of MyNewService. When you renamed the service in step 3, the class name was not modified in the Main method. To access the Main method in VC#, expand the Component Designer generated code region.
static void Main()
{ 
    System.ServiceProcess.ServiceBase[] ServicesToRun; 
    //Change the following line to match. 
    ServicesToRun = new 
        System.ServiceProcess.ServiceBase[] { new MyNewService() }; 
    System.ServiceProcess.ServiceBase.Run(ServicesToRun);  
}
In the next section, you will add a custom event log to your Windows service. Event logs are not associated in any way with Windows services. Here the EventLog component is used as an example of the type of components you could add to a Windows service.
To add custom event log functionality to your service:
  1. In the Solution Explorer, right-click Service1.vb or Service1.cs and select View Designer.
  2. From the Components tab of the Toolbox, drag an EventLog component to the designer.
  3. In the Solution Explorer, right-click Service1.vb or Service1.cs and select View Code.
  4. Edit the constructor to define a custom event log.
To access the constructor in Visual C#, expand the Component Designer generated code region.
public MyNewService()
{
 
    InitializeComponent()
    if(!System.Diagnostics.EventLog.SourceExists("DoDyLogSourse"))
    System.Diagnostics.EventLog.CreateEventSource("DoDyLogSourse",
                                                          "DoDyLog");

    eventLog1.Source = "DoDyLogSourse";
    // the event log source by which 

    //the application is registered on the computer

    eventLog1.Log = "DoDyLog";
}
To define what happens when the service starts, in the code editor, locate the OnStart method that was automatically overridden when you created the project, and write code to determine what occurs when the service begins running:
protected override void OnStart(string[] args)
{ 
    eventLog1.WriteEntry("my service started"); 
}
The OnStart method must return to the operating system once the service's operation has begun. It must not loop forever or block. To set up a simple polling mechanism, you can use the System.Timers.Timer component. In the OnStart method, you would set parameters on the component, and then you would set the Timer.Enabled property to true. The timer would then raise events in your code periodically, at which time your service could do its monitoring.
To define what happens when the service is stopped, in the code editor, locate the OnStop procedure that was automatically overridden when you created the project, and write code to determine what occurs when the service is stopped:
protected override void OnStop()
{ 
    eventLog1.WriteEntry("my service stoped");
}
You can also override the OnPause, OnContinue, and OnShutdown methods to define further processing for your component. For the method you want to handle, override the appropriate method and define what you want to occur. The following code shows what it looks like if you override the OnContinue method:
protected override void OnContinue()
{
    eventLog1.WriteEntry("my service is continuing in working");
}
Some custom actions need to occur when installing a Windows service, which can be done by the Installer class. Visual Studio can create these installers specifically for a Windows service and add them to your project. To create the installers for your service.
  1. Return to design view for Service1.
  2. Click the background of the designer to select the service itself, rather than any of its contents.
  3. In the Properties window, click the Add Installer link in the gray area beneath the list of properties. By default, a component class containing two installers is added to your project. The component is named ProjectInstaller, and the installers it contains are the installer for your service and the installer for the service's associated process.
  4. Access design view for ProjectInstaller, and click ServiceInstaller1.
  5. In the Properties window, set the ServiceName property to MyNewService.
  6. Set the StartType property to Automatic.

Tip

To avoid being asked about the system username and password you must change the Account for the serviceProcessInstaller to LocalSystem. This is done by opening the ProjectInstaller design and then selecting the serviceProcessInstaller, press F4 and then change the Account property to LocalSystem. Or you can manually do that by creating a class that inherits from System.Configuration.Install.Installer like this:
[RunInstaller(true)]

public class ProjectInstaller : System.Configuration.Install.Installer 
private System.ServiceProcess.ServiceProcessInstaller 
                                  serviceProcessInstaller1;
private System.ServiceProcess.ServiceInstaller serviceInstaller1; 
/// <summary> 
/// Required designer variable. 
/// </summary> private System.ComponentModel.Container components = null;

public ProjectInstaller()
   // This call is required by the Designer.
   InitializeComponent();

   // TODO: Add any initialization after the InitComponent call 
} 
private void InitializeComponent() 
{ 
   this.serviceProcessInstaller1 = 
     new System.ServiceProcess.ServiceProcessInstaller(); 
   this.serviceInstaller1 = 
     new System.ServiceProcess.ServiceInstaller(); 
   // serviceProcessInstaller1 
   // 
   this.serviceProcessInstaller1.Account = 
     System.ServiceProcess.ServiceAccount.LocalSystem; 
   this.serviceProcessInstaller1.Password = null;
   this.serviceProcessInstaller1.Username = null; 
   // 
   // serviceInstaller1 
   // 
   this.serviceInstaller1.ServiceName = "MyNewService"; 
   this.serviceInstaller1.StartType = 
     System.ServiceProcess.ServiceStartMode.Automatic;

   // 
   // ProjectInstaller 
   // 
   this.Installers.AddRange
     (new System.Configuration.Install.Installer[] 
   { 
       this.serviceInstaller1, 
       this.serviceInstaller1});
   }
}

To build your service project

  1. In Solution Explorer, right-click your project and select Properties from the shortcut menu. The project's Property Pages dialog box appears.
  2. In the left pane, select the General tab in the Common Properties folder.
  3. From the Startup object list, choose MyNewService. Click OK.
  4. Press Ctrl+Shift+B to build the project.
Service Project Property Page
Now that the project is built, it can be deployed. A setup project will install the compiled project files and run the installers needed to run the Windows service. To create a complete setup project, you will need to add the project output, MyNewService.exe, to the setup project and then add a custom action to have MyNewService.exe installed.

To create a setup project for your service

  1. On the File menu, point to Add Project, and then choose New Project.
  2. In the Project Types pane, select the Setup and Deployment Projects folder.
  3. In the Templates pane, select Setup Project. Name the project MyServiceSetup.
A setup project is added to the solution. Next you will add the output from the Windows service project, MyNewService.exe, to the setup.
Service Setup Project

To add MyNewService.exe to the setup project

  1. In Solution Explorer, right-click MyServiceSetup, point to Add, then choose Project Output. The Add Project Output Group dialog box appears.
  2. MyNewService is selected in the Project box.
  3. From the list box, select Primary Output, and click OK. A project item for the primary output of MyNewService is added to the setup project. Now add a custom action to install the MyNewService.exe file.

To add a custom action to the setup project

  1. In Solution Explorer, right-click the setup project, point to View, then choose Custom Actions. The Custom Actions editor appears.
  2. In the Custom Actions editor, right-click the Custom Actions node and choose Add Custom Action. The Select Item in Project dialog box appears.
  3. Double-click the application folder in the list box to open it, select primary output from MyNewService (Active), and click OK. The primary output is added to all four nodes of the custom actions — Install, Commit, Rollback, and Uninstall.
  4. Build the setup project.

To install the Windows Service

Browse to the directory where the setup project was saved, and run the .msi file to install MyNewService.exe.
Service Setup

To start and stop your service

  1. Open the Services Control Manager by doing one of the following:
    • In Windows 2000 Professional, right-click My Computer on the desktop, then click Manage. In the Computer Management console, expand the Services and Applications node. - Or -
    • In Windows 2000 Server, click Start, point to Programs, click Administrative Tools, and then click Services. Note: In Windows NT version 4.0, you can open this dialog box from Control Panel.
  2. You should now see MyNewService listed in the Services section of the window.
  3. Select your service in the list, right-click it, and then click Start.
Right-click the service, and then click Stop.
Admin tools Services

To verify the event log output of your service

  1. Open Server Explorer and access the Event Logs node. For more information, see Working with Event Logs in Server Explorer. Note: The Servers node of Server Explorer is not available in the Standard Edition of Visual Basic and Visual C# .NET.
    Sample screenshot

To uninstall your service

  • On the Start menu, open Control Panel and click Add/Remove Programs, and then locate your service and click Uninstall.
  • You can also uninstall the program by right-clicking the program icon for the .msi file and selecting Uninstall.

Tuesday, 5 October 2010

How to – Silverlight Developer runtime not installed

When I went to watch PRISM video, it prompts and told me I do not have latest silverlight, even though I was using SL4. Regardless I went and downloaded the SL exe and ran it. Now after installing the SL component my development box kept failing that I do not have Silveright developer runtime. I figure the download I got to watch video messed up my development box and I was right.

A quick bing got me to the following URL

http://forums.silverlight.net/forums/p/188683/433499.aspx

which tells the same. There are two versions of SL distributable, one for developers and one for the end users. The one I downloaded was end users, which in turn overwrote my developer version. Above link also have link to download location. I downloaded the exe from the link and now everything is green and peachy.

Thursday, 23 September 2010

How to test your anti-virus

We all will have an anti-virus or two installed in our system for sure. Once I want to test the anti-virus I have installed. I cant risk my system by directly installing an anti-virus. Then i came across this method of creating a fake virus. The procedure to test the anti-virus is as follows:

  • Open notepad.
  • Copy the below code in the file.
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


  • Then save it with the name fakevirus.exe

    If this file got deleted immediately that means your antivirus is working and updated. Try it.

Sunday, 5 September 2010

Shortcut Keys to Shutdown and Restart your Computer

Hi Friends,
I just learned the shortcut keys to shutdown and restart our computer or laptop. Well this is not necessary but you guys know I like playing around with my computer. Don’t you think it is better if your computer shutdown or restart with just a double click of your mouse.
So get ready and follow these points to experiment, be creative yaar.

  1. On your desktop, right click>shortcut(select shortcut)
  2. You will then see a Popup Window(Create Shortcut wizard)
  3. In ‘Type the location of the item’, Key in ‘Shutdown -s -t 01′

You might be thinking what does -s -t stands for, just hold on I will explain later.
shortcut keys to shutdown, shortkut shutdown
Click ‘Next’ and you will be prompt to name the Shortcut. Give it any name you want and click ‘Finish’.
Now, whenever you hope to shutdown your Computer or laptop. Simply double click on this shortcut icon.
You can also fully customize this shortcut Icon.
Right Click>’Properties’>’Change Icon’
This allows you to change Shortcut Icon to any image you want.
If you want to create a Shortcut Icon for restarting your Computer or Laptop, Simply change -s to -r.
As s stand for shutdown while r stands for restart.
Change the number after -t to set the time of your Computer and Laptop to wait in seconds before shutting down.
You can also insert a comment by adding -c ‘Your Text’ to the line. It will display the Text you specified while counting down the time in seconds.
So how is the tricks, did you try??? Leave a message if you liked it.

Friday, 13 August 2010

Binding A Custom Entity Class to stored procedure using Linq-To-SQL

Linq, its a great ORM that we can use in various way. The purpose of this post to demonstrate How we can bind custom entity to stored procedure result with use of Linq-To-SQL. Let’s go through it and you will realize that how easy it will be to bind a Custom Entity to Stored Procedure result.
Let’s first create a simple table to which will hold the user data. It will contain four field like UserId,UserName,FirstName and LastName like following.

SQLTable

Now let’s insert some data into the table like following.

SQLTableData

Now let’s create a stored procedure which will return the table data and a new field called Full Name like following. Here full name is a combination of first name and last name

01.CREATE PROCEDURE dbo.GetAllUsers
02.
03.AS
04. SET NOCOUNT ON
05. SELECT
06. UserId,
07. UserName,
08. FirstName,
09. LastName,
10. FirstName + ' ' + LastName AS [FullName]
11.
12. FROM dbo.Users

After creating a stored procedure it time to create a Linq-To-SQL Right Click Project->Add New Item and Go To->Data and Add LINQ to SQL Classes called MyBlogDataContext.dbml.

After creating datacontext class for Linq just drag above store procedure to Linq-To-SQL classes and it will create a function like following.

StoredProcedureInLinqClass

Now let’s add a New Entity Class called UserInfo into Linq-To-SQL DataContext via Right Click Add New Class Just like following.

AddClass

After adding class I have added same property as its having in user table and Hence our UserInfo Class will look like following.

UserInfoClass

Now everything is ready Custom Entity Class called UserInfo and we have Our Function ready which will return Stored Procedure output. Here Linq-To-SQL Provides a property called ReturnType If you select function which we have created via dragging a stored procedure in data context class. We just need to select our UserInfo class there just like following and it will bind the stored procedure with that particular UserInfo class. here only condition should be satisfied that Our Custom Entity class should contain all the field with compatible .NET Data types which will return the data. Below is the property which we are talking about.

SelectProperty

Now let’s add grid view to default.aspx page like following and Let’s bind output of stored procedure to that grid view.

1.<asp:GridView ID="grdUserList" runat="server">
2.</asp:GridView>

After placing the Grid View in page here is the code for biding grid view in default.aspx page_load event.

01.protected void Page_Load(object sender, EventArgs e)
02.{
03. if (!Page.IsPostBack)
04. {
05. using (MyBlogDataContextDataContext myContext =
06. new MyBlogDataContextDataContext())
07. {
08. List<UserInfo> MyUserList =
09. myContext.GetAllUsers().ToList<UserInfo>();
10. grdUserList.DataSource = MyUserList;
11. grdUserList.DataBind();
12. }
13. }
14.}

And here is the output which we get in browser after running our web application.

Ouput

That’s it its very easy.. Hope this will help you…

Wednesday, 11 August 2010

Where is IPagedCollectionView?

This is nothing but a sticky note for me than a post. I downloaded a project and when I tried compiling the project I got an error from the compiler that it couldn’t find IPagedCollectionView. I checked the name space of the class in my other box and it pointed me to System.ComponentModel, I checked the references and I do have that dll. (One thing I did not check was to double click open the reference and see if the class definition there). Anyway, I went directly to the trusted source regarding these kind of problems, Microsoft msdn web site and found the missing dll. Even though the name space points to System.ComponentModel. the class definition is in System.Windows.Data.dll. So for future reference if you run into this problem, now you know, where it is :)

http://msdn.microsoft.com/en-us/library/system.componentmodel.ipagedcollectionview(VS.95).aspx

Wednesday, 4 August 2010

Full screen mode in SilverLight 4

In one our project page it was requested to show the silver light content in Full screen, with out IE headers, tool bars etc., you can achieve this by simply pressing F11. I guess it is a power option and most of the users would not know this command. One option is document it and train. I guess you all know how that one goes. I knew there was a solution to this problem since I have seen examples of silver light media playing movie clip in full screen mode. I looked around on net and found the following link. But before you go there and try out, it will not work in SL4. I am putting the link for documentation purpose of the initial approach taken in SL2.

Tips and Tricks in Silver light (Full screen in SL2 not SL4)

The concept is straight forward. If the full screen option is selected, the browser host will blow up to full screen. Something changed from SL2 and SL4. After more research on the web, found the solution in the following link and I thought I share it with you for anyone looking for full screen solution in SL4. The link is not only to identify what changed in SL4 to get full screen mode but also all the changes in SL4. This is a good reference to have, since most of the net searches bring back SL2 or 3  version of solution, refer the following to find if it changed or not. If changed what is the correct way to do it in SL4.

Full Screen Mode in SL4 and other changes to SL4

Friday, 30 July 2010

Random information on Silverlight

Just want to document two things I came across yesterday.

First one is an error:

This morning one of my colleague try to check out my application and try out. They were able to compile successfully and when he ran the application, he got an error

WCF RIA services will fail unless the silverlight project is hosted in and launched from the same web project that contains the WCF RIA services

This happens when you have you silverlight application (client side) set as the startup project. All you have to do is set web as the start up project and assign the .aspx or .html as the start up page and you are all set.

Second one is tip:

I have created a simple application which consumes a model set to connect to a database. Which worked fine. Now I have to change it to a different data base to do some volume testing. That data base has same table and scheme etc., To do that for your testing purpose, simply go to web.config on the silverlight web project and change the initial catalogue. This is for ad-hoc testing but if you would need to do more frequently, then do it in the server side code based on some parameters.

Friday, 23 July 2010

How to Secure a Wireless Network from Hackers?

The reason we secure a wireless network is to stop people from using the services of our network who don't have permission to utilize them. It is harder to secure a wireless network from hackers as compared to a classic wired network. This is due to the fact that a wireless network can be accessed anywhere inside the range of its antenna.
In order to secure a wireless network from hackers, we should take proper steps to save ourselves against security issues. If you don't secure a wireless network from hackers, you might end up without its service. The consequence might also include the utilization of our network to attack further networks. To secure a wireless network from hackers, you should follow these simple wireless networking tips:
1.       Strategic antenna placement:
The first thing you have to do is to position the access point's antenna in a place which restricts the range of its signal to go further than the required area. You should not put the antenna close to a window because glass can't obstruct its signals. Place it in a central location of the building
2.       Use WEP:
WEP stands for Wireless encryption protocol.  It's a customary technique for encrypting traffic on a wireless network. You should never skip it as that will allow hackers to get instant access to the traffic over a wireless network.
3.       Change the SSID, disable the broadcast of SSID:
SSID stands for service set identifier.  It is the recognition thread utilized by the wireless access point due to which the customers are capable of starting connections. For every wireless access point arranged, select an exclusive as well as unique SSID. Also, if it's attainable, hold back the broadcast of the SSID out over the antenna. It won\t appear in the listing of offered networks, while being able to provide services as usual.
4.       Disable DHCP:
By doing this, the hackers will have to decode the TCP/IP parameters, subnet mask as well as the IP address in order to hack your wireless network.
5.       Disable or modify SNMP settings:
Change the private as well as public community settings of SNMP. You can also just disable it. Otherwise the hackers will be able to utilize SNMP to get significant info regarding your wireless network.
6.       Utilize access lists:
For additional security of your wireless network, and if your access point support this feature, employ an access list. An access list lets us determine precisely which machinery is permitted to attach to an access point. The access points which include the access list can employ trivial file transfer protocol (TFTP) now and then in order to download modernized lists to steer clear of hackers.

Thursday, 22 July 2010

Using LightTPD with XAMPP on windows

I recently setup LighbetTPD on my machine because there is a need for me to use LightTPD server to achieve a video delivery with HTTP Pseudo-Streaming.  I decided to install it on windows since I use windows more often for development. The H264 streaming module works well on Apache but I am working more with the FLV streaming module which works well on LightTPD. I once tried installing mod_flvx.c on RH5 for Apache but it seems not to work well for me.

I had to dive into LightTPD and I think it’s a great decision. Prior to the installation of LightTPD on windows, I use the Apache on XAMPP as my web server. So, I will like to show you how I use the PHP (and MySQL – this will work well anyway, as far as the service is running) in XAMPP for LightTPD. You may be thinking; “why would you wanna do that since there is a WLMP webserver package that has all in one?”. Well the answer is: “I want to keep my Apache server and I don’t want to have two MySQL server or have two instance of php.ini file”. So follow this simple steps:

Firstly, download the Win32 version of LightTPD from the WLMP Project; I prefer using the win32 version, you can use the .zip one if you want to.

Double-click on the downloaded file to install LightTPD on windows. By default, the installation directory is “C:\Program Files\LightTPD” but I mine was installed in D:\LightTPD since my XAMPP is in the same D:\ drive.

After completing the installation, you will need to start the server by going to the LightTPD directory and look for the file ‘TestMode.bat’. Double click on it to start the server; a console window opens to indicate the server has started successfully. If you have port 80 in use, you will come across an error saying: can’t bind to port: 80 Address already in use. The default server.port on LightTPD is 80. Since my Apache is runing on port 80, I will have to modify the lighttpd-inc.conf file for LightTPD to work with an alternative port like 81 or 8080.

Open [LightTPD-Directory]\conf\lighttpd-inc.conf, remove the comment for server.port = 80 and modify the value to whatever port you want to use; as far as it’s not in use. Mine is server.port = 81. Save and run the ‘TestMode.bat’ again. If everything is set properly, the server will start.

Navigate or point your browser to http://localhost/ or http://127.0.0.1/ to see if LightTPD server is working.

Now you will have to configure the lighttpd-inc.conf to work with PHP. The PHP I used is actually that of XAMPP as I mentioned earlier. So modify cgi.assign value to “.php” => “D:\xampp\php\php-cgi.exe” [D:\xampp\ should be your XAMPP installation directory]

Modify other necessary lines you will/might need.

mod_flv_streaming is need (by me)
mod_rewrite is so need ( by me )
and so on.

To avoid the cygwin warning seen earlier, set the server.document-root value to have a forward slashes without the D: or C: as in “/Inetpub/wwwroot/”

After all modification, save the file; press Ctl+C on the console window to shutdown the server and re-launch, i.e double-click on ‘TestMode.bat’ to start the server again. You can also set LightTPD to run as a service. Open [LightTPD-Directory]\bin\ and double-click on Service-Install.exe to install the service.

You are set and good to go. To test if PHP is working, create a .php file with this content

1   <?php phpinfo(); ?>

Place the file in the htdocs directory, mine is D:\Inetpub\wwwroot\ and navigate to the URL, i.e http://127.0.0.1/info.php. You should be able to see the standard phpinfo() details.

That’s it!

I hope you’ll get this if you want to install LightTPD this way. Thanks for reading and please leave a comment to let me know how far it goes.

Thursday, 8 July 2010

Order Matters – LINQ

One of my colleague ran into this problem when using LINQ to join two tables. The problem is that he has two tables a & b where he is joining tables on column called key on both the tables. Following is what he had in the beginning

var list = from firstTable in a

              join secondTable in b

              on firstTable.Key == secondTable.Key

              select a;

This is a very straight forward query. On first glace there is nothing wrong with that. But when he tries to enter the above mentioned code, VS 2010 did not let him complete and was give error “The name ‘secondTable’ is not in scope on the left side of ‘equals’”  Couple of things you have to remember when you are using Linq to do joins

  • The order of comparison matters. So always use first table first and compare it against second table.
  • All LINQ joins are equijoins. so instead of using == you should use equals

So the correct LINQ query should be like the following

var list = from firstTable in a

              join secondTable in b

              on firstTable.Key equals secondTable.Key

              select a;