Build “Out of Browser” Applications with Silverlight Jun 20, 2010 SILVERLIGHT   VISUAL STUDIO

If you think that Silverlight applications are only intended to be run on web browsers, then you are wrong! Silverlight is now widely used to build Rich Internet Application (RIA) allowing users to work more efficiently and make a working session more interactive and attractive. As we all know a customer will always seek for a short-cut method, he will never listen to your comments or suggestions and wants everything to be done in few mouse clicks. A lazy customer! You build an application with a lot of effort and upload it to the user or customer’s website. Now the customer wants the same application for his desktop - he doesn’t want to open browser and work. Writing the same application again for his desktop won’t help and will also waste a lot of development time, why can’t we make the same Silverlight application to run from his machine?

Silverlight gives you an option to install the Silverlight application from the browser to your desktop called “Out of Browser” application support. Consider if you have built a game on Silverlight and upload it to your blog/website allowing you reader or visitors to play the game. It’s not just the case with games but same can be done with applications or with some general web utility like URL shortening service using Bit.ly API.

To get started create a new Silverlight application in Visual Studio 2010.

Creating a new silverlight app in Visual Studio

Give the name to your application and click OK.

Create new silverlight app

Design your application put the business logic in (if any). Once you are done designing and building the application go to the project properties. Click Project > APPNAME Properties. APPNAME represents the name of your application. In the project properties check the “Enable running application out of browser”.

Enable out of browser support for the application

Out-of-Browser Settings button will get enabled which will let you choose out of browser application settings.

Out of browser app settings

The settings dialogue box is quite self-explanatory. You can set the name of the application which you want to put on the window when it runs out of the browser. You can also set the icon for you application in different sizes. Click OK to save settings.

Now, run you application. You will see your Silverlight application running inside your browser. If you want the application to run out of the browser then right-click anywhere in the browser and click “Install onto this computer”.

Out of brower application

This will prompt you to install the application and place the application icons on your desktop or on your start menu or both. It will give your application the default application install icon. If you have set your own in the Out of Browser Settings then you will see your icon.

Installing out of briwser application

Now your Silverlight application is on your system and can be executed at user’s desktop.

URL rewriting in Blog Engine.NET Jun 5, 2010 BLOGENGINE.NET

was just looking for a way to get short URL’s for my blog, I used some extensions, some URLrewriter.NET but still not able to get this work. So I drop an e-mail to Scott Hanselman and was waiting for his response. If you look at Scott’s blog you will see that he has very simple URL for his blog posts which eventually get his posts higher ranks on search engine indexing. What I have found so far is that if you have a simple URL the search engine will crawl that page during indexing and your page is on the top of the search results or if it is not on the top then it must be at least on the first page. Remember search engine crawlers will avoid crawling pages that do not have a simple URL, like if your page has a query string it won’t be get crawled by the search engine crawler.

The URLRewriter module in BlogEngine didn’t seems to be working for Posts. I want to have simple SEO friendly URLs like http://www.midnightprogrammer.net/post/Windows-7-Logon-Screen-Changer.aspx and not http://www.midnightprogrammer.net/post/2010/05/30/Windows-7-Logon-Screen-Changer.aspx But there is no way to do this until I hook into BlogEngine.Core.dll.

Open the whole solution in Visual Studio and open Post.cs file and navigate to the RelativeLink property in Post.cs file and change with the below code:

public string RelativeLink
{
    get
    {
        string slug = Utils.RemoveIllegalCharacters(Slug) + BlogSettings.Instance.FileExtension;
        if (BlogSettings.Instance.TimeStampPostLinks)
            return Utils.RelativeWebRoot + "post/" + slug;
        return Utils.RelativeWebRoot + "post/" + slug;
    }
}

Recompile your DLL and place in bin directory in your blogengine root folder. Now you will have short URLs which do not have any date stamp. Having short URLs for all your posts doesn’t affect the posts with old URLs that most of the people have bookmarked on their blogs or on social bookmarking sites. Hope this helps.

Windows 7 Logon Screen Changer May 29, 2010 C#   PROJECTS   UTILS   WINDOWS

Works on my machine

Recently I was reading an article on some Windows 7 forums on how to change Windows Logon Background. There are manual steps which helps me to change the longon background, but its tedious if I have to do it manually everytime. So I decided to make a tool which can do it for me.

I start up a new project in Visual Studio 2010 and create a new windows application. I am not writing about how I did it, I am just giving away this tool for use. Just Browse and click Change Logon Screen and you are done.

Windows 7 logon screen changer

Press WIN+L to lock your computer and check your new logon screen. There is only one limitation, you cannot select an image which is larger than 256KB.

Download: Win7 LogonScreenChanger.zip (49.21 kb)

Source Code: Win7LogonScreenChanger.zip (139.44 kb)

How To Build UAC Compatible Application In .NET May 23, 2010 C#   UTILS   VISUAL STUDIO   WINDOWS

We all know about a feature called User Account Control (UAC) which introduced with the launch of Windows Vista. By default, UAC is enabled and provides users a better and safer computing experience, but most of the users find it irritating when the UAC prompts everytime they try to run a program. Disabling UAC is not recommended at all.

With UAC enabled programmers find it difficult to access some of the locations on the local drive. Programatically you cannot write or create a file or directory in root partition, inside Program Files, System32 folder and some other locations. Recently I ran into a same problem where I have to access System32 folder, create new folders and copy files from one location on my system to this folder. With UAC disabled this is pretty easy, no security settings and no runtime errors or exceptions. Usually you cannot ask the users to disable UAC and then use the application, so therefore I made my application compatible with UAC and YES!!! you will be prompted with the confirmation box to run the application with administrator privileges. In Windows Vista and Windows 7, even if you are an administrator of your machine you do not have the complete access to resources even if you are an administrator. So in order to make your application run with full administrator rights follow the steps below. This will work the same if you run your application with “Run as Administrator” option which you see when you right-click the application.

Create a new application in Visual Studio. Right-click project and add a new item.

Adding application.manifest file

From the Add New Item box select Application Manifest File.

In the manifest file un-comment the following line:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Shield icon after UAC enabled

Build your applicaton….and when the build is complete you will see the security shield icon accompanying your application icon. A dialogue box appear in front of the user to run the application with full administrative privileges.

Akismet Extension For BlogEngine.NET May 14, 2010 API   BLOGENGINE.NET

Since I have started using BlogEngine.NET I never thought of using any other open source blog engine. To me BlogEngine is the most extensible blogging platform availableat present. As a popular blogging, engine blog engine users faces a lot of spam comments. I was so totally annoyed and even after moderating comments I have to manually go and delete the comments. After some search I found an extesion from Joel Thoms. Simple and easy to use, dont even require moderation.This extension passes the commnets to Akismet spam database which then checks approves or disapprove commnets.

To get it working you need an API Key which you can get for free at http://akismet.com. Once you get an API key extract the files in App_Code/Extensions folder and jump to your Extension section under Settings.

Akismet extension settings

Once you save your settings you are done. NO MORE SPAM.

Download: AkismetExtension.zip (3.55 kb)