Upgrade to iPhone OS 4 and lose everything

A while back, when I was syncing my iPhone, a message popped up to say that there was a new version of the iPhone OS and that I should upgrade. Without much thought, I upgraded to the iPhone OS 4 and was very happy that I had the latest software for my iPhone.

A few days later, I noticed that some of my pictures were gone. Some recent pictures that I took when on holiday had disappeared. I blamed it on the upgrade and thought that at least I had the majority of my pictures.

Some time after that, I noticed that my music library had completely gone. So I’ve got an iPhone with no songs or videos. Seems like I’m using the iPhone for calling and nothing more now.

Since I use WIFI at home, I’m set up the iPhone to connect to my home broadband and every now and then I use it. What I didn’t realise is that wifi on the iphone connects you to the mobile carrier of your iPhone service provider and at the end of the month, I was presented with a bill of £25 just for data. I called up O2 and they said that I’ve used that much in terms of internet data and I was furious because with OS 4, iPhone has changed the way the network connection used to be. I’ve got a perfectly good computer at home and I would be silly to use my Iphone for internet if I have to pay for it when I’ve got broadband free at home.

I’ve had to completely delete the mobile carrier name from my iphone to prevent any further charges (delete mobile.02.co.uk). If you’ve got data included in your package, then you’re fine (idata.o2.co.uk) but having to pay unfair charges because Apple forgot to mention that they were changing the network properties in iTunes is ridiculous.

So if you’re upgrading to iPhone OS 4, you’ll definitely be in for a surprise!

Combining ASP.NET website into a single assembly

With a Web Application Project (WAP), you get a single assembly when you build your project. However with an ASP.NET Website, the output is spread among many dll files. The closest you will get is having all your classes in the AppCode folder in one assembly and the other classes in separate assemblies. Depending how many files you’ve got in your website, this can amount to a lot and I think having one single assembly is better for a number of reasons, the primary one being deployment onto a production server.

Instead of converting my ASP.NET website to a Web Application Project, I decided to use the aspnet_compiler.exe to build the website output and use aspnet_merge to merge the assemblies together. This means that everything for the website will be in one single assembly but note that other assemblies that you’re referring to will stay the same such as log4net, nhibernate etc.

You will need to go to Visual Studio Command Prompt to issue the following commands:

aspnet_compiler -v TestWeb -p “C:\Projects\TestWeb” “C:\Projects\TestWebCompiled”

aspnet_merge “C:\Projects\TestWebCompiled” -o Gis

This will first compile your website files and then merge the assemblies. You may encounter the following error when you use the aspnet_merge tool though:

aspnet_merge: error occurred: An error occurred when merging assemblies: ILMerge.Merge: ERROR!!: Duplicate type ‘FooterControl’ found in assembly ‘App_Web_xd23ggdz’.

In my case, it was because I had two web controls with the same name. I had to delete one of them but you can just rename yours and it should work fine afterwards.

There’s a great video at http://www.asp.net/general/videos/how-do-i-use-the-aspnet_mergeexe-utility-to-merge-assemblies showing you how to use the both the asp.net compiler and the asp.net merge tool.

The only thing I need to figure out now is how to remove certain files/folders from being compiled.

Cannot install iTunes on 64 bit Windows 7

I’ve installed Windows 7 64 bit on my computer which had Vista previously and I was in the process of adding the softwares that I use often when it came to iTunes on my list, problems started occuring. I downloaded the iTunes for windows (64 bit) without any problems but couldn’t get it to install. I’ve read on the web that quite a lot of people were having trouble downloading the iTunes setup package itself but my problem was different.

When I double click on the iTunes installer, it shows the progress bar for a split second and disappears. So I googled the problem and found that a lot of people were having the same problem. I know I’m using the 64 bit version of Windows and I downloaded the right package for my OS. On Apple’s website, I’ve tried everything listed on there. I’ve cleaned up my TEMP folder (in AppData under my username), remove all the programs (Bonjour service, QuickTime etc) and even changed msconfig to go onto selective startup as suggested by apple to no avail. I’ve had to uninstall Adobe Master Collection CS3 Suite to remove that annoying bonjour service and edit my windows features to delete everything from the TEMP folder and nothing worked.

I’ve spent hours on this and it’s really frustrating that I can’t sync my iPhone because Apple released a crap version of their iTunes installer. It’s not like there’s something wrong with my PC because I’ve got a fresh install of Windows 7 on it. So blame Apple! I’ve tried different versions, mix and match QuickTime as a standalone program or QuickTime with iTunes and nothing will get the iTunes install. I’ve even tried it on 3 separate computers! Now this surely is a joke, isn’t it?

Out of desperation, I installed a 64 bit version of iTunes 8.0 instead of iTunes 10.1.1 and got that to install without any problems. However when I plugged in my iPhone, iTunes complained that it was not compatible and that I needed to upgrade to the latest version (10.1.1). So all that for nothing. Deleted the old iTunes, tried again and back to square one. So now I’ve got an iPhone with no songs on it and I can’t sync it. Well done Apple.

UPDATE 08 Feb 2011 : I’ve just downloaded iTunes Setup 10.1.2  for Windows 64 bit and it installed without any problems. However when I plugged my iPhone to the computer, it did not recognise it. So I went to Device Manager in Control Panel and there was the little exclamation icon next to the “Apple Mobile USB Device” and I had to manually update the driver but after that I was able to sync my iPhone.

Designing an email notification system in asp.net

I’m currently working on a Question/Answer website and users are notified of new answers to a question they’ve subscribed. Similarly emails are sent out when there are new comments to an article for which you’ve subscribed. The other types of emailing present in the system is when a user registers for the first time and an activation email is sent out to them or when they send a request to reset their password through a “Forgotten Password” link or when the administrator wants to send out an email to every member (kind of a broadcast or newsletter thing).

To me, the registration and password reset email need to be sent straight away for a good user experience. So this can be done synchronously as soon as the registration form is completed or the password reset button is clicked. However when a user adds a new answer/comment, you cannot have the same worker process handle the notification, that is, send emails to subscribed users to tell them there’s a new answer/comment. This will be bad experience for the user who submitted the answer/comment because the request will be blocked until the emailing is done and if you have to notify 100 users, this can take a really long time.

There are a few things which can be done though such as getting the email sending to be done asynchronously, relaying the emails from IIS SMTP to the mail server or using MSMQ (Microsft Messaging Queue) to queue up the emails.

Sending emails asynchronously in C#

With .net 4.o framework, it has become even more easy to send emails asynchronously. You will need to have the Async property to true in the Page directive and use SendAsync instead of Send on the smtp object (you need to hook up the delegates as well but I’m not going into that for the time being).

What happens then is that the worker process which served the http request will be returned to the application pool once the async method is hit and another thread will be processing the asynchronously event. Once it is complete, the response is then sent to the user. The advantage of doing this is that you free up worker processes to serve other http requests instead of starving the thread pool. When your async job is finished, another worker process will be grabbed to finish off the request which had the async method.

The main disadvantage of the async page is that the user who initiated the request will have to wait until the async event completes before he sees any response. If you’re doing heavy work (as in emailing 100 people), then the user can get really frustrated and leave and that’s not very good for user experience. Http requests need to be quick and process intensive tasks need to be done by a background thread.

What we really need is a fire and forget method and that can be achieved with a background thread (see this link http://www.jdconley.com/blog/archive/2009/01/14/fire-and-forget-email-webservices-and-more-in-asp.net.aspx). Context switching is an expensive task though and the problem with this approach is that the thread will go into unmanaged code, so you will need to be careful what it’s doing.

IIS SMTP relay to remote mail server

Using the System.Net.Mail library is great but communicating through the SMTP protocol is an expensive task. First a connection has to be established with the remote mail server and then the destination email address needs to be checked and if it exists, then the delivery of the email can be done. Now imagine doing that for a large amount of emails. It will take a really long time. Therefore it is much easier to use PickupDirectoryFromIis or SpecifiedPickupDirectory for the SmtpDeliveryMethod.

If you use Network delivery, then the email will be sent through the smtp protocol but if you use PickupDirectoryFromIis, then the email is saved as a file in the \inetpub\mailroot\pickup folder with the .eml extension. Email files are easier to process and since you’re not connecting to the remote mail server and simply saving the emails as files, you will find it much quicker to process.

Once in the pickup folder though, you will need a certain process to deliver the emails. You can get IIS Smtp to deliver the emails directly or have it relay to your remote mail server.  The latter is the better approach since your mail server can do the spam checking and authentication and will not be blacklisted by other email servers.

IIS SMTP on Windows 7 and Windows 2008

It is important to note that Windows 7 does not come with a version of the IIS SMTP server. With Windows 2008 though, you can get the SMTP installed by going into Features and adding it but it runs in IIS6 mode and not IIS7 or IIS7.5. Therefore you will need to have IIS6 running on your server even if you use IIS7/7.5 for your websites.

The IIS SMTP service should be used as an email relay in the sense that email dropped in the pickup folder are forwarded to the actual email server (smtp) for processing.

Using Microsoft Messaging Queue (MSMQ) to notify users through email

A queuing system is a good way to send email as MSMQ can help with that. Basically, instead of sending the emails directly to the mail server through the network, you save the messages in a queue with MSMQ. They will stay in the folder they’re saved and another process (eg a windows service) can read that folder and process the emails (deliver them). The main advantage to this is that you do not overwork your CPU as in 100% at peak times and 0% during non-peak hours but rather use the CPU in a more efficient manner because the work is queued up and can be processed when resources becomes available.

The following link is a good start (http://dotnetslackers.com/articles/aspnet/Sending-email-from-ASP-NET-MVC-through-MVC-and-MSMQ-Part2.aspx).


The mechanism behind sending mass emails to users who have subscribed to a particular service is very important because you do not want your users to wait a long time because there’s a slow process which has been triggered by some action they’ve taken on your website. For the user, things must be quick and it is therefore important to have background tasks run on a different thread than the calling thread.

Question and Answer websites – Q&A

Knowledge should be easily shared and made available to others without having to pay an excessive amount of money. Ideally it should be free but there are times when that’s not possible. However I believe that many individuals have a lot of knowledge and experience which could be helpful to others and if these people were to share what they know, then life would be a lot easier to deal with.

I’ve always been fascinated with Question and Answer websites because the potential of these systems is really huge. At one point in everyone’s life, there comes a time when you have this doubt/question and you want someone to point you in the right direction. By yourself, it can take a substantial amount to time to resolve the problem but if someone was there to guide you, then it would make the hurdle easier to cope with.

My idea of a Q&A website is a place where people can ask questions no matter how trivial they might seem and get answers from other people. Of course, there’s no guarantee that the answers received will definitely resolve the problem in the said question but at least it can give the asker an idea how to go about solving the question. Sometimes there may be someone who’s had the same problem before and can therefore post a really good answer which would address the question being asked or there might be experts in the question field and therefore, it would be easier to tackle these questions objectively.

The Q&A system would need to have a reputation system whereby people who contribute constructively are rewarded in the community. This can be in the form of different levels attached to a user’s profile or points accummulated over a period of time. Not only does this show how engaging the member is but an answer from a reputable member is worth more attention than that from a person who posted his first answer. This is not to say that a novice cannot provide a great answer but when someone has built a reputation, it is easier to trust their contribution.

Questions can be voted on and rise up the scale when it gets really popular. This can be used to show that a lot of people actually like the question and think that it is interesting. They may not have asked the question themselves for one reason or another but are grateful that some other person has.

Answers should be votable as well and this helps to show which answers are better and which ones are not so good. When this happens, answers with more votes rise to the top and that helps a person searching for that particular question to easily locate the answer which more accurately addresses the question instead of the searcher having to go through all the answers and see which one is the best. Similarly a best answer option is a great way to label great answers and this should take that answer to the top of the page just below the question so that it is the first thing that you see when looking at a question.

Of course with such a system in place, it is upto the community to moderate the content that is being posted. So there must be a mechanism in place to report offensive content and members must be encourage to use that feature. Points should be awarded for doing good karma and the same applies for people trying to spoil the community, that is, negative points and when it gets below a threshold, an automatic ban is issued.

Articles for more in depth information

The question/answer website takes in generally a short question and several short answers. Most of the time, it is something very specific and there’s no need to go in details if a one line phrase can answer the question. This is why is believe that a section should be created for articles where indepth coverage of certain topics can be discussed. For example, an article on “Electric cars” might discuss the various technogies used and the best cars that we have so far whilst a question labelled “What is the best electric car” requires a 1 liner stating the make/model for the best electric car. However a link from the question page to the article page would be really helpful as a person looking for more information on the subject matter can read more.


I think that contests are a good way to engage the members of the website. You could do a contest for the best night photography and let members upload their best pictures and have other members rate/vote them. The one with the highest vote can receive a badge or something more tangible sent to him.


Poll is another good way to have your users interact with your website more. Polls can be anything really eg, have a list of 10 songs and ask users to vote on their favourite. At the end of a pre-determined time, you can close the poll and show the results to everyone.

Multiple networks in Windows 7 – Unable to connect to the Internet

After upgrading my Vista PC to Windows 7, I installed a few programs that I use frequently and was hoping everything was going to be fine. However things turned out to be a headache when I could no longer connect to the Internet. I connect to the Internet through a network cable that comes straight from my Netgear router, so there couldn’t be any wireless problems. I tried to hover over the little network icon in the system tray and it showed a message telling me that I was connected to multiple networks. I knew straight away that this was the problem and if I could get rid of multiple networks and make it connect to just 1 network (my home network), then that would solve my problem. Strangely enough, there was no option to delete the other network m (Public Network) from Windows.

I tried a few things and the only thing that worked was to disable the network adapter and enable it again. This would get rid of the multiple network problem and connect to my home network as it should do. However when the computer is restarted, the problem would come back again. I wanted to find a more permanent solution to the problem. So I searched on the web and it turned out to be a problem with a service called “Bonjour Service”. That’s  a program from Apple and basically it kicks in before another service and that’s where the problem starts. If you go into services, you will not find a service called Bonjour Service as it’s named some like “##IdString1…”. You will have to set that service to delayed autostart or disable it to get your internet working again.

The Bonjour Service got installed on my computer when I installed Adobe Photoshop CS3 but if you use iTunes, you are bound to have it as well. It’s a perfectly safe program but should be marked as Start type – Automatically (delayed) if you want no hassles with your internet connection.