Blog is moving

September 5, 2014 Leave a comment

I will be moving the content of this blog to http://arabellsoft.com where I will continue to blog.

Please follow me there.

Categories: Uncategorized

WPF Did you Know Series: You can run XAML from Internet Explorer

Dear reader,

It’s being a while, I know.  Got married, changed jobs, moved cities, and a newly minted daddy to a beautiful daughter.

Saying that, I started reading “WPF Unleashed by Adam Nathan” and I thought I would blog and share some of the things I learnt reading the book.

So it goes, did you know you can run XAML code from Internet Explorer? I certainly didn’t know this and I have being programming WPF circa 2009. You can by:

  1. Save your code in a .xaml file
  2. Open the .xaml file from Internet Explorer.

That’s me for the day. Enjoy programming in WPF.

PS: Apparently this will work in FireFox too with an add-on. Please share your thoughts on your experience with this.

Categories: Uncategorized

Apps I Use

Sometimes I get asked what apps I use on my phone and iPad.

On my Google Nexus S, I mostly use:

  • Chrome Beta: it looks quite sleek. Google has done a good job in laying the tabs browsing very well. You could even see the preview of the tabs when you click on the tabs button that shows you how many tabs you currently have open.
  • Evernote: What can I say about this great app? The UI has greatly evolved overtime. The app now commands a clean-looking interface that is so easy to use. I have now ditched my hardcover notebook at work. I could create and update ideas, To Do/To Go lists, share notes, record presentations, shopping lists, links, etc. The app is simply brilliant!
  • Pulse: This app has become my de facto app for reading news. The guys at Pulse have taken reading news on your portable device to another level. You can add new sources, scroll the different news items, follow the category you’re interested in and swipe back and forth in full screen mode. Just awesome!
  • WhatsApp: This is my “to go” app for keeping touch. I reach out to friends and folks that are not in Canada easily without having to think about international text cost. I mostly use the image sharing functionality but you can share other things like videos, sound, maps and contacts with your contacts on the app.
  • CoPilot Live: This is a very handy utility for getting directions. Although, Android phones by default come with the free Google Maps and Navigation, there are times you don’t have data signal to navigate to your destination. CoPilot to the rescue!
  • Dropbox: Simple – great for keeping your files on the cloud.
  • TED: Very good for getting inspired by great people.

For my iPad, I will add the list soon. Stay tuned.

Categories: Uncategorized

Do you get confused identifying which w3wp.exe to attach to in Visual Studio?

Two options for you:

Option 1 (from command prompt)

– In IIS 6: run %windir%\system32\cscript iisapp.vbs

– In IIS 7: %windir%\system32\inetsrv\appcmd.exe list wp

This should give you process id with the corresponding application pool you’re interested in.

Option 2

  1. Open Windows Task Manager
  2. Add PID and Command Line to the Processes tab
  3. Find the w3wp.exe processes
  4. Look for your application pool under the Command Line tab.  Make a note of the PID
  5. The PID is the ID of the process you need to attach to in Visual Studio

I prefer option 1 as it explicitly displays your list of application pools and process IDs.

Hope this helps to solve the frustration we sometimes go through when you have so many application pools running in IIS.

Enjoy!

Custom Type in C# Settings

Today I was working on having custom type for settings in C# and I couldn’t see my type when I browsed for it in the Settings.settings visual designer in Visual Studio 2008.

I was able to get round the problem following the steps below:

1. Open your Settings.settings visual designer in Visual Studio.

2. Click on the dropdown for Type.

3. Click Browse… in the dropdown.

4. In Selected type: paste your full namespace. E.g. MyCompanyName.Project.SubProject.CustomType

5. Click OK and now you should have your custom type in your application settings.

If this help saves just one person some time, I’ll be happy!

Have a good day.

Categories: Uncategorized

My take on Android 2.1

September 9, 2010 Leave a comment

Two weeks back, I went into my local phone store here in Vancouver to get myself a Huawei U8100 with Android 2.1. I previously owned Windows Mobile 6.5 for about two years. After this, a Samsung which unfortunately was stolen at my local swimming pool. This is my take on the Android mobile platform:

Likes

  • Big User Interfae improvement compared to when Android first came out but still looks semi-basic compared to iPhone.
  • It has a pattern unlocking feature which means you shouldn’t need to remember a PIN, which I think is great.
  • If you have a Gmail account, it syncs very well. I was able to get a bunch of my contacts back. You will appreciate this feature, if your phone was stolen, got lost or changing to a new phone.
  • Also related to Gmail, I could get my Calendar synced with the phone with no hassle.
  • Kindle for Android: This is a great app that works very well with Android.
  • Handcent SMS is another great app that makes you want to send SMS every minute! You can even set thumbnail pictures of the people you having a conversation with. I think this is way too cool!
  • Google Maps: found it very useful when I’m up-and-about for directions, maps and transport links.
  • The apps market has a great feature of searching for the kind of app you want. No need browsing through the thousands of apps available.
  • You can use your choice of browsers. Currently, I’m trying out Dolphin Browser. This browser is looking really good.
  • Contact list allows you to connect with your faceBook account and you could decide to only display contacts with phone numbers. This I think is a very useful feature if your contact list is huge and you don’t want your faceBook friends all over your phone.
  • Touch screen keyboard has big keys that could fit my fat finger!
  • In terms of games, I sometimes play Air Control. This could get addictive sometimes.
  • It supports PDF documents.

Dislikes

  • Apps are littered all over the phone, which could sometimes make looking for an app a slight pain in the bum. It could have been more categorized.
  • The touch screen is not as smooth as it could be. Sometimes it could be jumpy!
  • The Music app that came with the phone can be a bit clunky.
  • The default SMS application just looks too plain.

These are just my own personal opinion about the Android 2.1 platform.

Categories: Android Tags: ,

Are you unable to load due to AppBase location issue in NUnit?

Error

I have been getting this error lately: System.ApplicationException: Unable to load ‘NUnitAssemblyName’ because it is not located under the AppBase—->
System.IO.FileNotFoundException: Could not load file or assembly ‘NUnitAssemblyName” or one of its dependencies. The system cannot find
the file specified.

Environment

  • Windows 7 32-bit
  • NUnit version 2.5.3.9345
  • Visual C# Express 2010
  • .Net Framework 4

Screenshot from NUnit:

Solution

So I made up my mind to get to the bottom of it. Apparently, to solve the puzzle was staring me right in the face and it is quite simple as:

  1. In NUnit, click Project -> Configurations and set the applicable build type for your NUnit project.
  2. Click Project -> Edit… and click ApplicationBase browse button and point the location to your NUnitProject_directory\bin\<Build_Type>, where Build_Type could be Debug, Release, etc.
  3. In the future, as soon as you create your NUnit project, be sure to take steps 1 and 2 before adding your NUnit assembly.

That’s it. Hopefully this hint will save someone trouble for the day!

Categories: Errors Tags: ,

Attribute cannot be added after a sub-element node

May 7, 2010 1 comment

Background

The other day, I was working on an XSLT that transforms XML into HTML page. By fluke or some other means I got this error I wasn’t prepared for:

Error

Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node has already been added.

XSLT Source Code

I repeated the error by creating this XSLT code.

<xsl:template match=/Books>

<html>
<body>
<h2>Select a book to read today:</h2>
<xsl:element name=select>

<xsl:attribute name=name>books</xsl:attribute>

<xsl:for-each select=Book>

<xsl:element name=option>

<xsl:value-of select=Title/>

<xsl:attribute name=value>

<xsl:value-of select=Title/>

</xsl:attribute>

</xsl:element>

</xsl:for-each>

<xsl:element name=select>

</xsl:element>

</xsl:element>

</body>

</html>

</xsl:template>

XML Input

<Books>

<Book>
<Title>OOP Demystified</Title>
<Author>James Keogh</Author>
<Language>English</Language></Book>

<Book>
<Title>Spoken from the Heart</Title>
<Author>Laura Bush</Author><Language>English</Language>

</Book>

</Books>

Solution

The error message is self-explanatory really. To get round this problem, we need to move “<xsl:value-of select=Title/>”

to after the attributes we wish to set. This is because the attributes for that element will need to be set first before all the

values are set.

<xsl:template match=/Books>

<html>

<body>

<h2>Select a book to read today:</h2>

<xsl:element name=select>

<xsl:attribute name=name>books</xsl:attribute>

<xsl:for-each select=Book>

<xsl:element name=option>

<xsl:attribute name=value>

<xsl:value-of select=Title/>

</xsl:attribute>

<xsl:value-of select=Title/> <!– Move to here, after attribute –>

</xsl:element>

</xsl:for-each>

<xsl:element name=select“/>

</xsl:element>

</body>

</html>

</xsl:template>

Tips

  1. Debug your XSLT by opening it in Visual Studio.
  2. Point to the input XML from the Properties window for the XSLT page.
  3. Put breakpoint as you would normally do.
  4. Transform the XML by clicking Debug XSLT in the XML Editor on the toolbar. Don’t press F5/F6!
  5. Then you could start to use your usual debugging keys like F10, F11, etc.

Have fun debugging your XSLT!

Find Regular Expression for words that contain only letters?

April 24, 2010 Leave a comment

Problem

Return words that only contain letters a-z and A-Z.

Output

Return True or False if there’s a match.

Source Code (in C#)

static bool IsAllLetters ( string input )

{

Regex rg = new
Regex ( @”^[a-zA-Z]+$” );

return rg.IsMatch ( input );

}

Notes/Analysis of Source Code

The regular expression pattern contains: “^[a-zA-Z]+$”.

  • “^” matches the word from the beginning of the word.
  • “[a-zA-Z]” character class matches letters a – z and A – Z of the alphabets.
  • “+” quantifier
    matches 1 or more characters in the character class enclosed in the square brackets.
  • “$” matches the word to the end of the word.

Test Code (in C#)

static void TestIsAllLetters()

{

string[] words = { “.”, “a.b”, “the”, “dog”, “cat”, “!”, “1foo”, “foo2”,

“123foo”, “giant10.do*gs.dogs” };


foreach ( string word in words )

{

Console.WriteLine ( string.Format ( “Does \”{0}\” contain all letters? {1}”, word,

IsAllLetters ( word ) ? “Yes” : “No” ) );

}

}

Output

Getting started with Windows Azure

March 26, 2010 Leave a comment

I got the idea of blogging about Windows Azure and Cloud Computing from a Microsoft MSDN Event I attended in Seattle, Washington in March 2010. It was titled Cloud Computing and Azure. I have since gotten hooked after the event to see where I can learn a thing or two about cloud computing and Azure. In my quest to learn, I’ve decided to blog my encounter with the exciting technology by trying it out under the program Try Windows Azure in March and Win a Notebook. My aim here is not to win a notebook (still great if I win!) but to experience it from a developer/user’s perspective.

Registration

WARNING: Windows/SQL Azure is a paid-for service. You will need your credit card to register and deploy your application to the cloud.

I signed up for a trial offer using my credit card here with the Windows Azure Platform Introductory Special. This offer will allow me to try the Windows Azure platform at no charge which includes a subscription of:

  • 25 hours of compute hours
  • Windows Azure with 500 MB of storage. Windows Azure is the operating system as an online service.
  • SQL Azure – 1 Web Edition database. SQL Azure is simply a cloud database.
  • AppFabric – allows connection for cloud services and on-site applications.
  • Access control transactions and service bus.

Note: The offer ends July 31, 2010. After then, the standard rates will apply.

Instructions

  1. Close Visual Studio if you have it opened.
  2. Download and install Windows Azure for Microsoft Visual Studio from here. This includes the Windows Azure SDK.
  3. You can go ahead and start both Development Fabric and Development Storage from Start | All Programs | Windows Azure SDK v1.0.
  4. Create yourself a new project from Visual Studio by clicking File | New | Project.
  5. Notice there is a new section called Cloud Service under Visual C# or Visual Basic. Click on Cloud Service and click Windows Azure Cloud Service. Enter a name for your cloud project and click OK.

  6. The “New Cloud Service Project” window will come up as below:

    Add “ASP.NET Web Role” and you can rename the title by highlighting the item on the right frame. Go ahead and rename it to “AzureWebRole”.

  7. After you click OK, open up Solution Explorer and notice the headings “AzureWebRole” and “CloudService1”. AzureWebRole is your usual ASP.NET web project and the additional project is CloudService1. This differentiates it from the normal ASP.NET web application and makes the project a Windows Azure cloud application.
  8. Now, create a new project from http://windows.azure.com
    and sign in.
  9. Click on a project
    under Project Name.
  10. Click New Service.
  11. You will have two options but for the sake of this article, click Hosted Services:

  12. Enter a service name and description.
  13. Enter a public service name, check for availability and choose the appropriate region as below:

  14. After you have successfully created the service, you will get a screen as shown below:

  15. Now go back to the cloud service project you created in Visual Studio and right-click CloudServices1 and click Publish. A window will popup as below:

Copy the path to the location circled from the address bar and dismiss the window.

16. Now go to the Windows Azure web page and click Deploy as shown below:

17.  Click Browse under “Application Package”. Paste the path you copied previously and select “CloudService1”. You could tell this is the right file by making sure the type says “Service Package file”.

18.  Now, click Browse under “Configuration Settings”. This time select “ServiceConfiguration”.

19.  Once the deployment is done, you will see a screen as shown below. Make sure you understand the content of the page to avoid unnecessary charges to your credit card!Be sure to click Run. This might take a few moments. This action will enable, initialize and get your deployment ready for production. You will see the update below when your deployment becomes live:

That’s it; you can now click on your live cloud application under Web Site URL to go to your application on the cloud.

Clean up

Be sure to delete your service if you do not want to get charged on your credit card or if you do not wish to continue use of the service. Delete by clicking Suspend and click Delete afterwards.

Make sure you get a screen similar to the one below. Then you could be sure you would not continue to incur charges.

To be double sure you DO NOT get charged, you can go ahead and delete the service completely by clicking Delete Service:

Finally…

Go ahead and have fun with Cloud Computing and Azure technologies!