I believe I am a little late in talking about the new .NET logo Microsoft showcased at the PDC 2008.
You could certainly get more on msdn but Scott Hanselman has posted some of them on this blog post.
I believe I am a little late in talking about the new .NET logo Microsoft showcased at the PDC 2008.
You could certainly get more on msdn but Scott Hanselman has posted some of them on this blog post.
Posted by Abhang Rane at 7:42 AM
I am sure most of the IT guys, especially managers are familiar with the word Peopleware. For those who don’t, it originated from a popular book called Peopleware: Productive Projects and Teams by Tom DeMarco and Timothy Lister. It actually underlines the constant conflicts between individual work and corporate ideologies, something most of the software developers face, but hardly speak about. Its a concept which if understood and followed by managers, can result in great work culture, lesser employee turnovers and higher productivity. If you intend to know just what the heck I have scribbled here, then jump to the conclusion below, although please read the book if you haven’t.
I have been a full time employee in India and later in US, which has inspired me a lot to write this post. An important factor which affects the productivity of a developer is the attiture of their manager towards them in day to day activities. There is a startling difference between the companies based in India and those in US (Well other countries too but I have had experience of US only). I would quote a statement from the book mentioned above,
“Managers are not supposed to make people work, but make it possible for them to work.”.
This statement has such a deep meaning in its own sense. I could expand on this giving my own experience at work. While in India, I constantly had a feeling that the manager to whom I was reporting, was really difficult to approach to. The extremely vertical structure of the Indian software industry results in the developers being less communicating and more bullied by the managers. If you imagine a organization structure chart, the white spaces between these levels signify the place where learning should occur. But in most of the Indian firms I feel this space is void or close to void. The result is the manager thinks of the developers as nothing more than replaceable parts of a working machine. When such a feeling is in the air, developers have a depressing attitude towards their work and company. In this case, either the developer’s performance degrades and they eventually leave. Most of the managers would get on with that by hiring a new developer in that place and life moves on. Only good managers realize that this will cost the company much more than spending some on the efforts for retaining that developer. The main theme of the book is quoted as,
“ The major problems at our work are not so much technological in nature than they are sociological in nature”.
Honestly I feel there is heck of a difference in the kind of job done in majority of software firms in US and in India. The Indian office of an US counterpart is an offshore development place wherein the work is “supposed” to be done quicker and cheaper. This is the mantra of a global service firm. Although, the offshore office is not an exact counterpart of its western office since things are dealt slightly different here. A developer has to manage his/her everyday tasks along with maintaining communication with the manager. At the end of 8 hours of code crunching, he/she might have to attend a phone or video conference with the client since it is day time at the client, the client needs to talk personally what is going on in the codeville. So you see, typically in a IT service firm in India, a developer has much longer day than usual. Most of the developers have put this in their routine but they know it unknowingly, that they are losing precious amount of time of their life which is just one per person. Overtimes, late night drops are a real common thing among the IT firms here. Well the sad thing is, its the nature of the job which seem to demand it.
Frankly, many people have seen this dieffrence between big fat companies and startups. Most startups or small companies are more open cultured, flat due to its size with a well managed office and the meat of the dicussion, the managers have a closer relation with the team members. For me atleast, if the job does not give me the joy of work I need, the salary ain't worth sqaut. I do not say that all startups and small companies are better to work for than big companies, but as a budding developer I feel more interesting and challenging to be in a small pond rather than an ocean. Talking about startups, people interested in starting a new business, may be in IT or something else must read the blog post about The Art of Bootstrapping by Guy Kawasaki.
IT managers in India have to realize that developers are real asset to a project and not replaceable parts. Low quality software product, delayed projects, scrapped out projects are a result of sociological problems in a team rather than a technical one. The book mentioned above openly explains the mistakes manager have been doing until now, some still do. Good managers spend time and money in hiring good people and trust their capabilities rather than telling them what is to be done at each point of time.
Developers need to realize that the reason you intend to work hard is because you like it and evetually wanna have a better life. But what is the point of that life if you spend your twenties and thirties in a cubicle or an office doing overtime crunching millions of lines of code. Most of us do realize this fact and just keep going, but when you eventually feel like stopping its all over.
Slow down you crazy child,
And take the phone off the hook and disappear for a while.
Its all right, you can afford to lose a day or two,
When will you realize … Vienna waits for you?
-- Billy Joel.
Posted by Abhang Rane at 10:53 AM
I know I know I am a PC guy! But I could not stop myself buying an iphone as soon as it was released in 2007 being a techjunkie. I enjoyed legally using it when I was in US. Like a honest buyer I used the AT&T sim, paid the bills blah blah. But I had this big question in my mind, what the f*** would I do when I move to India. When I returned here earlier this year iphone was not yet released and the only way to use it was unlocking it. But yet again like an honest buyer I played the wait and watch game, I thought Apple would certainly come up with a plan for people changing their region with the old 2G iphone. But instead they released iPhone 3G here for country which is yet to have a 3G network! So I was left with 2 options, either buy a new iphone in India or unlock my 2G iphone. Hah, like I was gonna be honest anymore!
Thus began my tryst with the hackers. I followed lots of blogs about unlocking it and came across lots of folks with horrible error messages on their iphone sometimes rendering the iphone in recovery mode. No doubt unlocking is a risky business but I had to do it. I spent 2 nights figuring out the error messages I used to get while unlocking it for the first time. Finally I got it right with the following steps for 3 different updates which makes it a pretty much foolproof method. Frankly Pwnage tool is really made for a non-technical person and the errors which we get are some exceptional cases only. Again, these are the steps that have worked for me for all updates until the latest 2.2 update.
Steps for unlocking iphone 2G –:
1) Remove the SIM card. I have found this step important for later activation. Take a backup of your iphone.
2)This is a step many people might not follow but I have found doing this step avoid the 1600 error we get at the end of the process. If the iphone is never unlocked then jump to step 5, if it is, restore the iphone with a .ipsw file downloaded from apple. For ex. while updating to 2.2 my iphone was already pwned to 2.1.1 version. So I restored it to the 2.1 ipsw file I had from apple. If you do not have that file you can look on the internet for it, lots of guys have kept copies of these files. Same procedure must be applied for further updates.
3) Restoring the iphone to an earlier version as described above will take some time. TO restore, connect the iphone, once iTunes fires up. cancel any message boxes for updating the iphone to new versions. Hold Option and click Restore. I think it is Alt on Windows. This will allow you to select a .ipsw file to restore with. While restoring the iphone will restart several times, you would see the apple logo indicating we are using a valid .ipsw file from apple.
4) Once restoration is complete you would get a message of no SIM card installed which is a good sign.
5) Now exit iTunes completely and fire up Pwnage tool. Select iPhone, expert mode and click Next.
6) Allow the tool to search for the restore bundle you downloaded from apple. By default the .ipsw file is in Library/iTunes/iphone software updates on a Mac. I generally transfer this file to a folder on a desktop to make the process easy. I have all the earlier restore bundles in this folder.
7) Select the restore bundle you need, mostly you would select the latest version in this case 2.2 version. Click next. On the next screen you would see several customization options. Select General and click next.
8) If you have a legitimate iPhone contract with your carrier (for instance, and iPhone contract with AT&T), you will need to uncheck the box next to “Activate”
If you don't have one, like me since I am in India with a US iphone I have left it checked.
Change Root Partition size to 1000MB for updating to 2.2.
8) Keep clicking Next until you reach the Build screen again. In between steps include changing icons etc which can be left as it is.
9) Let the tool build the Custom bundle for you, have a drink till then! Store the custom restore file on your machine somewhere. This file will be used to restore the iphone.
10) Once complete, you would get a message asking if your iphone was pwned before. Now since we have restored the iphone in the first step with a legal .ipsw file it is not pwned anymore and hence select No. In either case, if your iphone is pwned earlier or not select No in this step, of course assuming step 1 is done. Click Yes has resulted in 1600 error for me at least.
11) Now are the easy steps. Follow the instructions to get the iphone in recovery mode. You can use iTunes to do this but I prefer to use Pwnage. Once you get a message saying successfully in DRU mode or something, the Pwnage tool job is done!
12) Now move to iTunes. Since iPhone is in recovery mode, you will get an option of clicking the Restore button on iTunes. Hold Option and click Restore to select the Custom Restore bundle just built by Pwnage tool.
13) Now its time to sit back and relax. If anything was done wrong, you would get a 1600 error message just after extracting the bundle. This error message is such a piece of s#$$ that it does no help in understanding what the problem was.
14) I am assuming here that there were no errors till now and the iphone is getting restarted several times with a pineapple logo.
15) Once everything is done, the iphone will show off its home screen. Insert SIM card now. Restore the iphone with the latest backup you took.
16) You should have an unlocked iphone with all your data as before!
I have a feeling that even Apple enjoys playing this “cat and mouse” game with the hackers out there. If you are interested in what the great “Woz” has to say about this please watch this video http://news.bbc.co.uk/1/hi/programmes/click_online/7742797.stm.
Please let me know if you are stuck with some step. Hail the iphone dev team!!
Happy unlocking!! Someone's gonna get PWNED!!
Posted by Abhang Rane at 8:33 AM
“ Wherever you wander, wherever you roam
Always remember you are missed back home ”
Its been a while I wanted to blog about my experience of coming back to my home, India. Living in US was awesome, the time I spent for my Masters, the work I did with an American firm was a lifetime experience. But India was at the back of my mind all the time. When I decided to leave US for good, I was kinda dreading my thought. It is one heck of a big decision in my life. Quite frankly, staying away from home, studying there alone, working there and managing all the day to day things certainly makes us really smarter than before. May be some of us have already had that experience here in India, but I was always in my house during my graduation. I never stayed in a hostel or anything of that kind.Every night after work I used to search for blogs about guys who have already made their move to India. These blogs, and few of my friends who returned to India before me, really helped me make my decision.
It is really a personal choice whether to stay there or come back. I do not think there is anything unpatriotic about not being in India. But there is certainly a clear difference between the lifestyles. In US you will certainly earn well, of course expense is more but still the savings are more than done here. The work culture in American firms is just awesome. I enjoyed working every day for my company in Chicago. But you miss your family at other end. Being such a rich cultural country you certainly miss the festivals every year. I especially missed Diwali, it being such a vibrant festival :). Of course no need to mention the different cuisines we have here. Food is something Indians love from the bottom of their hearts and I bet there is no single restaurant, atleast in Chicago, which can make the kind of pav bhaji the guy at the corner of the street here in my city makes. If you love spicy fast food, Mumbai is the place to be baby!
Things that are different here
Internet Connection – Man, I was so much attached to my wireless since I was on my Mac all the time. Blogging, “ Youtube”ing, checking out pubs to hangout etc was a routine for sure. I was using 6Mbps Comcast high speed internet which was awesome. But in India, it is hard to find such luxury since wireless is not that penetrated in people’s lives. I found it really difficult to not use internet as I was using before. But now I use MTNL’s package which is uncharacteristically pretty fast and not really expensive. I brought my Linksys router with me which I use here in my house. So I am cruising on the internet these days. My package allows me to use unlimited internet after midnight which kinda works for me.
Pollution – This factor is especially for those returning to Mumbai. Pollution due to traffic has soared like hell. I had sore throat for first few days. I also had a viral infection, may be due to the vada pav I had, which went on for a week. It was just irritating being on bed all the time. After living in US for a while, my resistance power had reduced like anything which actually makes us vulnerable to infections here. But how much ever we complain about infection, fever, pollution blah blah blah, Mumbai is always missed, comon be true to yourself!
Parents :) – Yup, parents. I am currently living with my parents and brother in Mumbai. Let me tell you, after living with friends and doing all kinds of “stuff” in US, it is not very easy to give away all that freedom suddenly. Imagine to stop all that frequent pubbing and playing beer pong and what not. But all this comes with a little reward too. We are pampered like little kids all day. I do not need to do laundry, no need to cook, just get what I want. Uber cool!!
Job Search – This is something everyone would be thinking first before moving to a place after a while. To be honest, having a Masters on my resume, with some cool projects done on campus, and the work experience really boosts the chances of getting an awesome job here. May be this is obvious to everyone, but having such experience on the resume certainly makes it better than the majority, so you are in a much better position in finding a job you want here.
There are so many other things to talk about being back home. I really hope this experience of mine would help you make your decision to stay there or come back. Close yourself in your room and talk to yourself about this in front of a mirror. I am sure the only person who can solve this dilemma is the one looking at you. I am sure there will be a million people telling you what to do and what not to do. In my case people settled in US did persuade me in staying back. Finally I did what was in my mind all the time and I do not think my decision is the right decision. As I said, it is a personal choice after all!
Best of Luck!
Posted by Abhang Rane at 11:36 AM
I love reading books. I try to add a new book in my collection every 2 weeks or so. It’s just one of those things that I cannot quit until I die. The books I recommend are a mixture of technical and non technical books since I think it’s essential for a developer to be enlightened in all aspects of programming. Being a .NET guy my focus is mostly on C# and ASP.NET. The books are not in any particular order but I have loved reading each and every book in this list.I have provided ebook download links for some of them, go ahead and try downloading them.
1) C# in a nutshell – O’reilly ( For a beginner in C#) Download Here
2) CLR via C# – Jeffrey Richter ( For an experienced C# developer, highly recommended to gain in depth knowledge of the .NET runtime.)
3) Professional ASP.NET – Evjen, Hanselman, Rader ( A must have reference book for ASP.NET)
4) Essential ASP.NET – Fritz Onion (Must have book for clearing concepts in ASP.NET)
5) Essential ASP.NET with examples in C# – Fritz Onion (Must have book for clearing concepts in ASP.NET) Download Here
6) ASP.NET Ajax in Action – Gallo, Barkol, Vavilala ( Great book for beginner and experienced in ASP.NET Ajax framework) Download Here
7) Windows Presentation Foundation Unleashed – Adam Nathan ( I think it is the bible for WPF developers) Download Here
8) ASP.NET 2.0 Website programming – Marco Bellinaso ( Good ASP.NET book with a practical project example in the book) Download here
General Programming books
1) Introduction to Algorithms – Thomas Cormen ( Must have book to refresh algorithm knowledge if preparing for interviews :))
2) The Algorithm Design Manual – Steven Skeina ( Good book with examples on algorithm applications)
3) Head First Design Patterns – Freeman and Freeman ( My favourite book on design patterns, fun and work approach to teach design patterns, highly recommended for beginners to intermediate)
4) Design Patterns , Elements of reusable object oriented software – Gamma, Helm, johnson, Vlissides ( The bible for design patterns, although go through the head first book before reading this book, thats my personal experience though).
5) Code Complete – Steve McConnell ( My favourite book, a must have book for every developer on this planet!)
6) Rapid development, Taming wild software schedules – Steve McConnell ( An excellent book for good development practices) Download Here
7) A pragmatic programmer – ( A must have book for those who wanna be better programmers) Download Here
8) Programming Interviews exposed ( A nice book for preparing for interviews with companies like Microsoft).
9) Thinkertoys ( A nice book on creative thinking)
Some of these books have been taken from recommended reading sections of the blogs I follow. I can assure that all of these books have been “tested OK” by many important guys in the programming world. So go ahead and read them!
Posted by Abhang Rane at 3:08 AM
Frankly speaking since WPF was introduced every thing I do I feel its an animation!!
I used Kevin's (A guy who worked with me in my earlier company) Kinetic scrolling in my card game to display player names which was cool. I also used similar model to create a iphone like slider(the one which is used to unlock iphone).
Following is an excerpt from the code. Other events are similar to Kevin's scrolling example.
Here the endposition is the x coordinate of the rectangle which contains the sliding canvas.
protected override void OnPreviewMouseMove(MouseEventArgs e)
end = e.GetPosition(this);
if (end.X >= endposition)
double diff = end.X - start.X;
if (diff > 0)
TimeSpan time = etime - stime;
story = (Storyboard)FindResource("Timeline2");
DoubleAnimation anim = (DoubleAnimation)story.Children;
anim.To = start.X + diff;
anim.Duration = time;
Posted by Abhang Rane at 10:57 PM
Recently I have been working part time on a card game (simplified version of poker) using WPF. I had built some 2D games using Windows forms earlier but let me tell you, WPF is picture perfect for such applications. I have used Expression Blend for designing the game and Visual Studio 2008 for the code behind logic. (That’s a killer combination!). I would point out some important things which I feel WPF beginners would face while building a 2D game.
WPF Animation in code-behind
A 2D game made in WPF with no animation is hard to imagine to me. Expression Blend facilitates with hooking up events to a particular timeline(animation) created. But several times we might need to animate things in the code-behind. Here is a way to do it which I use a lot of times in my code.
Storyboard story1 = (Storyboard)FindResource([key]);
That was easy.
Mixing Windows forms with WPF forms.
Since I had few windows forms developed earlier which would be useful in this game, I thought of starting the application with a already existing windows form. This is not that difficult. A WPF application starts from the Main function located in the App.g.cs file (if C# environment) which is at the path projectrootdir/ obj/Debug. This Main function instantiates an object of class App,which is inherited from Application class, and runs it. The App.xaml file contains a StartupUri property to set the start form. Remove that property and a set an eventhandler for the Startup event of App class. In this event handler one can instantiate a form object as needed. The Application xaml tag looks somewhat like this:
I will be continuing this blog in later posts diggin into more complex parts. Be in touch.
Posted by Abhang Rane at 10:56 PM
I am working on building a website consisting of some “cool stuff” using some of the Microsoft features like Silverlight and ASP.NET Ajax. I have pretty simple but handy chat on the web using update panel control. I think with the same structure multiple chat rooms can be built. I also made a customized listbox in Silverlight. The listbox can be modified as you want just by putting in some extra code.
Custom Silverlight ListBox
I have used the Listbox control provided in the Silverlight.Samples.Controls.dll which is located in the Silverlight 1.1 installation directory. The complete path might look like this
C:\Program Files\Microsoft Silverlight 1.1 SDK Alpha Refresh Sept 2007\Tools\SilverlightControlsStarterKit\SilverlightUIControls\ClientBin
To get this path, you would have to build the project file in the directory. Sometimes Visual studio does not allow to reference a dll which is hidden under many diectories. If you add a reference to such a dll you might get an error like the reference path is too long. So copy the dll into your project Bin directory and then add a reference to it. There is a small bug in this Listbox control which was mentioned and fixed as per Vivek Dalvi’s blog. Find the UpdateLayout function in the Listbox.cs file and locate the
Clip = clip;
statement. Replace this by ActualControl.Clip = clip; That’s it. I should have told you this before asking you to reference the dll :).
Now is the time to create items which could be added. The ListBox.Items.Add accepts parameter of FrameworkElement. So the default xaml controls could be added to it but I have not tried all of them. I created a custom control to be added as an item to the listbox. I wanted to display textblocks with rounded corners inside this listbox. To begin with add a Usercontrol item to a Silverlight project. You could see in its code-behind a class inheriting from Control class is generated and some logic in its contructor. Observer the first line.
Stream s = this.GetType().Assembly.GetManifestResourceStream("Silverlightanim.BlogItem.xaml");
To successfully run the GetManifestResourceStream function the item which is given in the string must be marked as an Embedded Resource. If not, you might not get an error but it is just not executed. Following is the xaml code for the BlogItem which I add in the listbox.
Its really nothing heavy, its just has a rectangle with rounded corners and a textblock . Following is the code-behind file.
public class BlogItem : Control
Stream s = this.GetType().Assembly.GetManifestResourceStream("Silverlightanim.BlogItem.xaml");
rootCanvas = (Canvas)this.InitializeFromXaml(new StreamReader(s).ReadToEnd());
block = (TextBlock)rootCanvas.FindName("content");
this.Height = rootCanvas.Height;
this.Width = rootCanvas.Width;
public string BlogContent
block.Text = value;
As you see a public property has been declared which sets the text property of the textblock.
Now the final act of using the listbox and this blog item control on a silverlight page. For my project I am getting the data from an xml file which makes it easier to maintain later. Here is a sample xml file
xml version="1.0" encoding="utf-8" ?>
<Block Content="Hey John!!">Block>
<Block Content="Hey Jerry!!">Block>
<Block Content="Hey Nick!!">Block>
<Block Content="Hey Peter!!">Block>
<Block Content="Hey Charlie!!">Block>
Posted by Abhang Rane at 10:53 PM
Web based Chat with Ajax
Having a little chat window with a list of friends connected in the chat room is awesome! But the important thing is it should not be at the expense of the overall performance of the website. I created a website with other silverlight stuff on it and this Chat area as a side thing. I have used the ASP.NET Ajax framework which is pretty simple to use.
Follow the steps and at the end you would be enjoying a chat area on a web page.
Step1 : Creating the Chatter List
Drag a Script Manager on an ASP.NET page. If you create an ASP.NET Futures website, a script manager is already present.
Drag an UpdatePanel on the page and name it,say, chatterUpdatePanel. Drag a ASP.NET listbox control in the Update Panel. Behind the scenes a contenttemplate tag is created under the Update Panel. This is the area for the chatter names which will get update asynchronously.
I thought of having some basic authentication required before chatting. So I created a username and password textbox and a Sign In button outside the Update Panel. The click event of the Signin button must update the chatter listbox. To do this we need to specify a trigger to the update panel.
<asp:UpdatePanel ID="chatterUpdatePanel" UpdateMode="Conditional" runat="server">
<div id='hello' style="overflow:auto;width:146px" >
<asp:ListBox ID="listChatters" runat="server" Height="180px" Width="200px"
<asp:AsyncPostBackTrigger ControlID="ChatterTimer" EventName="Tick" />
<asp:AsyncPostBackTrigger ControlID="signin" EventName="Click"/>
The signin controlID is the Sign In button I used for signing in users. You can see another trigger with the control ID of ChatterTimer. Now if some friend of yours signs in at his house, everyone needs to know he signed in so I update the chatter listbox every 10 seconds. For this drag a ASP.NET Timer control on the page outside the update panel. Add a Async trigger to the chatterupdate panel with the event name as “Tick”. Thus every 10 seconds the listbox is updated without refreshing the whole page.
Step 2 : Creating the Messages Listbox
To display messages that are being sent, I use a listbox control. This listbox has to be updated independently of the Chatterlistbox. For this drag another Update Panel on the page and add a listbox in it. Call it say MessagesUpdatePanel.
There has to be an area where a chatter can type his statements and send them. I created a textbox and a button “Send” under the messages listbox. Make sure these two controls are outside the MessagesUpdatePanel. Add an async trigger to this update panel with controlid of the Send button and the event name as Click. Also since the messages come more frequently an update is required in a lesser interval. So drag a timer control and assign interval of 1 second and add an async trigger to the MessagesUpdatePanel with the control id of this timer control and event name “Tick” as follows:
<asp:UpdatePanel ID="messagesUpdatePanel" UpdateMode="Conditional" runat="server">
<asp:Label runat="server" Text="" ID="labelWelcome" ForeColor="#006699">asp:Label>
<asp:ListBox ID="listMessages" runat="server" Height="280px" Width="392px"
BackColor="Black" ForeColor="limegreen" Font-Names="Verdana">
<asp:AsyncPostBackTrigger ControlID="sendButton" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ChatTextTimer" EventName="Tick" />
Please be aware that the textbox which would be used to type statements must be outside the update panel since we do now want to update anything in it.
Step 3 : Storing chat data.
Now since we have the desig ready we need to have a way to store the chatters which have valid accounts. Also for my website I display the latest 10 messages in the messages listbox just for the heck of it I think :). I added a Global.asax file to my project to manage application level data. I have created a List<> of chatters in the global.asax.cs file as follows:
List<Users> chatters = new List<Users>()
List<string> messages = new List<string>();
In the Application_Start event I do the following:
Now since the Application object can be accessed in the Page too, I add any user which is created on the site into this list. Also as a messages is sent I add it in the messages list.
In the Page_Load event I load the chatters and the messages in the respective listboxes.
Following is a simple way to display List items in a listbox
List<string> messgs = (List<string>)Application["chats"];
listMessages.DataSource = messgs;
listMessages.DataBind();Similar procedure can be followed for chatter listbox too.
Posted by Abhang Rane at 10:47 PM
This week Microsoft launched Windows Live Tools for Visual Studio 2008 and Visual Web Developer Express. Its been an exciting experience for me to work on this project. Since I worked on these controls, I thought of sharing my ideas with you about effectively using these controls in your website. I would specifically focus on IDLogin and IDLoginView controls.
1) Download the Windows Live Tools installer from here. The dll’s are installed in Program Files/Windows Live Tools/ directory. Once installed a new tab of Windows Live Tools is created in the Visual Studio toolbox which contains the Live controls.
Design View errors in visual studio
Since Visual Studio 2008 is in beta stage there might be different experiences depending on the configuration of the machines. For some reason if you have problems seeing these controls in the toolbox or there is an error in the design view saying error creating control or something like that, close the IDE, open the visual studio command prompt and issue a command devenv /setup. This will reset IDE environment and possible get rid of the errors.
2) Open Visual Studio 2008 and click New Website. Here you would find a new website template called ASP.NET Windows Live Website. This template has all necessary settings for running Windows Live controls on a page. If you don’t want to use this template for some reason, make sure you have necessary settings on your existing website before using the controls.
For IDLogin control first add a Script Manager to the page since the IDLogin control is an Ajax server control and uses an Update Panel internally to do asynchronous postbacks. IDLoginView has to specific requirements. For specific requirements for Silverlight Media and Contacts control please refer to the Live website here.
Using IDLogin for Windows Live Authentication
This control can be used to authenticate users with their Windows Live ID account. This account is same account used for passport authentication.
Drag the IDLogin control on the page. This control needs a Live Application ID and Secret Key. To get this, click the action list button (little arrow button)on right top control of the control in the designer view.
Click the Create new Application ID link which opens a browser control. Click register an application and fill the details. After submitting those details an Application ID is provided by Windows Live which is unique to your application. Escape key closes the window.
The new Application ID and Secret is stored in an Appsettings section in your web.config file. The control uses this section all the time to authenticate your application so do not delete this section.
If you already have a registered application, paste the Application ID in the value field for wll_appid key and Secret in the value field for the wll_secret key. Save the Web.config file.
The control is ready to go live :). Run the website, a SignIn link is displayed on the page which when clicked takes the user to the Windows Live login page.
The control supports two client side events as OnClientSignIn and OnClientSignOut and two server side evens OnServerSignIn and OnServerSignOut. Further information about these events can be found here.
Important points to remember:
After Windows Live redirects to the return url you provided, the IDLogin control performs a redirect to itself. This is done to avoid firing of the sign in and sign out events every time a page refresh is done by the user. Thus you need to be aware of this fact that a redierct is happening because of the control which you might want to handle in your code. Ill post more such points if I come across while I continue working on them.
Make sure you read the Known Issues section on this link. These issues would be resolved in later releases of the controls.
In the next post I will show how to use IDLogin and IDLoginView control to effectively use ASP.NET membership account and Windows Live account and create associations between them.
Posted by Abhang Rane at 10:46 PM
Command line tools have always been my favorite, whether its a linux box or a windows machine. Its way cooler!! (don't know why). I use Powershell on Windows Vista and I really like for the fact that its designed in .NET environment which makes it easy to extend as you want. I am assuming you have basic information about Cmdlet and Snap-In classes for Powershell. If not, please refer to the the documentation which comes with Powershell installation.
I wanted a simple program to run in Powershell to display the temperature given the zipcode. I am going to show you how easy it is to add a new command in Powershell. A command like dir, ls etc. is called as a Cmdlet in Powershell. To use a new command in Powershell you need to do the following:
1) Create a .NET class which inherites from PSCmdlet. Add the functionality as required. This will be the custom Cmdlet class.
2) Create a new class in same namespace as the above class. The base class for this class should be PSSnapIn. This will be the custom Snap In class which is required to insert any Cmdlet in Powershell.
3) Register the Cmdlet using the SnapIn class we created.
Creating a Custom Cmdlet class
Nothing makes it more clear than a piece of code right. Here it goes!
public class TempCmdlet : PSCmdlet
private string zip="60606";
public string ZipCode
zip = value;
public object GetData()
Service1 service = new Service1();
object data = service.GetWeather(ZipCode);
protected override void ProcessRecord()
object data = GetData();
if (data.Length == 3)
WriteObject("Location : " + data.ToString());
WriteObject("Condition : " + data.ToString());
WriteObject("Temperature : " + data.ToString()+ " F");
This is my custom Cmdlet class. Observe the attribute to the class. This attribute shows that the command I would issue at the prompt would be Get-temp. The first part has to be a predefined verb in the VerbsCommon definition. The second part could be anything meaningful to you.
I am using a webservice to get the weather data by passing a zipcode to it. By default its 60606. Of course you could use a data store for the same thing. If you need any parameters to your Cmdlet you should create a Property and assign an attribute called Parameter. There are a bunch of values for this attribute but I used some common ones. The important function to look out is the ProcessRecord. This function is executed when the user invokes the Cmdlet at the prompt. Writeobject function actually writes the data to the output pipeline which is displayed to the user. There are several other functions which can be effectively used to improve the output but I did not go in that detail.
Creating a SnapIn class.
To register the Cmdlet , you need a custom SnapIn class. Here it goes again.
public class TempSnapIn : PSSnapIn
public TempSnapIn() : base()
public override string Name
public override string Vendor
public override string VendorResource
public override string Description
return "This is a PowerShell snap-in for the Get-temp cmdlet.";
public override string DescriptionResource
return "GetTempSnapIn,This is a PowerShell snap-in for the Get-temp cmdlet.";
Make sure you override all these properties, if not you would get some error when you try compiling this class. Place this class in the same namespace as the Cmdlet. Although I am not sure if different namespaces would work but you can try that.
Register the Cmdlet
We are ready to register our little Cmdlet created. This is the mose exciting part since we need to hit some commands in Powershell. Yessssssss!!
Open Powershell prompt.
Give the following commands.
PS> $ref = "$Env:ProgramFiles\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\System.Management.Automation.dll"
PS> $compiler = "$env:windir/Microsoft.NET/Framework/v2.0.50727/csc"
PS> &$compiler /target:library /r:$ref Codefile.cs
Codefile.cs should be the .cs or .vb file for your classes. This is the step to compile the code, you could obviously use the IDE to do this step.
Now to actually register the Cmdlet, use the InstallUtil program.
PS>set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil
PS> installutil Codefile.dll
Replace the Codefie.dll with your dll created in earlier step.
Now add the Snap In we created to the shell
We are done!! You could check by doing Get-temp at the prompt. Do not close the windows since you would lose all the settings you just did. Instead to save the session export the console as below.
PS> export-console MyCustomShell
If you have any particular questions about the code or anything else please reply to this post.
Posted by Abhang Rane at 10:43 PM
The IDLoginView control shipped with the Windows Live Tools control is a pretty good control for developers who want to customize the web page look depending on the Sign In status of the user. Normally, you would use a Login control on the page and once signed in with it, you could write a piece of code to display some items on the page which you want to display only to Windows Live Signed In users. Even more, if you plan to use ASP.NET Forms authentication for your website and customize the display for the users after being authenticated with it, you would write your own code to display them. IDLoginView control takes a step ahead and makes it way easy for the developer to assign templates depending on the status of the user visiting the page.
The IDLoginView control has 5 templates defined as follows:
The templates are self-defined here but the interesting one is the Associate Prompt. This prompt if defined for the control, will prompt the user whether to create an association between their windows live account and ASP.NTE website account. Of course for this template to appear one has to create a website account using the ASP.NET security configuration. Once an association is created, any time later if the user signs in Windows Live they will be automatically authenticated for the ASP.NET website.
Follow the following simple steps to use these controls on your page.
You could test your application by running the website and signing in Live and ASP.NET website. The prompt appears when you are signed in one of the accounts and then sign in the other account. To this to work you need the PromptOnAssociation to true.
Internally when you give an affirmative response to the prompt, a single row is added in the aspnet_LiveIDAssociation table in ASPNETDB database. You can see this database if you do show all files for the project. If you no longer want this association to take place delete this row from the table, for now, there is no UI to remove the association for the control.
I avoided thorough details about the control since you can find them here.
Cannot Open User Default database Error.
Bug: If you open the table to view the association entry, and then again try running the website you might get an error like Login failed for the default user. This bug is been posted on ASP.NET forums and many other places. I tried closing the IDE and reopening it. The website works, I think this is a bug with the SQL express since when it is open in the IDE, the error appears.
Posted by Abhang Rane at 10:42 PM
I really hope Apple and Google comes up with some storage mechanism on the iphone which would allow developers to really create applications which can be "online while offline".
Posted by Abhang Rane at 10:41 PM
Recently I had an opportunity to deploy a Desktop application which I was working on for few months into a production server. Microsoft has made the deployment procedure really simple and thus the name. But following the simple steps for the deployment may not succeed all the time(that is my experience). And that's why I sometime call it Click(More than) once deployment!! In general follow the steps as given below which consider some special conditions.
1) Right click the startup project properties. Clickonce deployment cannot be done without signing the manifest. Assembly signing is not required. In the Signing tab, the checkbox for Sign Clickonce manifest is automatically checked when you publish the app. The app is signed with a key (.pfx) created in the project.
2) Click Application Files to make sure all the files you need to be deployed in the project are present in the list. For ex, if you have added a .htm file somewhere in your solution, change its build action to Content. Since the startup project needs a link to this file to be deployed, add a link to the .htm file created in this project. To do this, click Add existing item in startup project. Select .htm file and click Add as link( a small arrow besides Add button).
Set the destination publish address(virtual directory). Click Publish Wizard to customize the folders if needed or Click Publish Now.
Some Caveats :
1) If prerequisites are required by your application, then proper bootstapper package need to be created for the same. To do this the quickest and cleanest way would be to use the Bootstrap Manifest generator. This creates the necessary files in the required location. You can find a step by step guide to use this tool here. Many other customizations could be done like adding Registry checks, file checks etc but those are not needed frequently. Restart VS editor and you should see the created package in the prerequisite list on the publish page. Select that and publish your project again.
2) Make sure that you have access to the virtual directory where you wish to publish this application. If for some reason you don't, publish them in some other folder where you have access and give this accessible folder's path to the virtual directory.
3) There is a publish.htm file created which by default is the starting page for the application. This is the page users will use to install the app. Make sure that the href value of the Install button is set to "setup.exe". Sometimes the value is set to the Application file which does not make sense since the whole reason for using clickonce is to bind the application and all other prerequisite packages into one file which is the executable "setup.exe".
4) There is a known bug in clickonce which I experienced too. On some machines which are used to deploy the application, once the app is published, clicking the RUN button on the publish page opens the setup dialog correctly but after that it opens a message dialog box with no text in it (wierd stuff!!). There is some discussion about this bug on this microsoft forum.
I have not covered the basics of this process assuming that you would know them. Although if you have any other questions, do leave a comment so that I can reply to it.
Posted by Abhang Rane at 10:39 PM