Sunday, July 20, 2014

The 'ProductID' attribute is invalid - http://WPCommontypesST_Guid

Recently I found something that might be a bug when creating cross platform projects using Xamarin.Forms.

The error exists in the Windows Phone 8 Silverlight project and does not exists in the Android nor the iOS projects. 

After project creation is completed, go ahead and build the entire solution (or in this case just the Windows Phone project). Potentially you'll get the error as below:



Because of this, you won't be able to compile the windows phone project at all.. sad! 
All is not lost, the good thing is that it is easy to fix! 
What you need to do is this..

Navigate to the Windows Phone 8.0 project and expand Properties. You will see several files on that section and one of them is WMAppManifest.xml file.


Next, double click on that file. You'll get this.


click the link "View manifest in XML editor" and choose "Yes" when the dialog popups up.



Find the the section ProductID and PublisherID.
It should look something like this in the xml:-


Now, what you need to do is put in open and close curly brackets for both ProductID and PublisherID






Save, the file, and close it. Double click on the WMAppManifest.xml file again. You will get this


Compile the project. The error is gone :)


I am not sure if this is a fix for it, but it does work in my case. 
I am happy!  :)


Happy coding!

Wednesday, July 16, 2014

String.IsNullOrEmpty() vs String.IsNullOrWhiteSpace

String.IsNullOrEmpty() vs String.IsNullOrWhiteSpace

So which would you use?


String.IsNullOrEmpty
String.IsNullOrWhiteSpace
Comments
.NET 2.0 and above
.NET 4 and above

Indicates whether the specified string is null or an Empty string.

Indicates whether a specified string is null, empty, or consists only of white-space characters.






- String.IsNullOrEmpty exists since .NET 2.0 and above
- String.IsNullOrWhiteSpace exists in .NET 4.0 and above


But which should you use?
Here's some useful answer from stackoverflow. 

Example:
string testString = "";
Console.WriteLine(string.Format("IsNullOrEmpty : {0}", string.IsNullOrEmpty(testString)));
Console.WriteLine(string.Format("IsNullOrWhiteSpace : {0}", string.IsNullOrWhiteSpace(testString)));
Console.ReadKey();
Resutl :
IsNullOrEmpty : True
IsNullOrWhiteSpace : True
************************************************************
string testString = " MDS   ";
IsNullOrEmpty : False
IsNullOrWhiteSpace : False
************************************************************
string testString = "   ";
IsNullOrEmpty : False
IsNullOrWhiteSpace : True
************************************************************
string testString = string.Empty;
IsNullOrEmpty : True
IsNullOrWhiteSpace : True
************************************************************
string testString = null;
IsNullOrEmpty : True
IsNullOrWhiteSpace : True

reference: 




happy coding!



Sunday, June 15, 2014

Behold... Xamarin 3 and Xamarin.Forms

amarin did it again.... This time with the release of Xamarin 3, my dream has come true. Xamarin 3, among other things has released a cool technology from their side called Xamarin.Forms

From my understanding, Xamarin.Forms is about a common set of API/Controls for developers to create great UI experience that can target different sets of platforms. Previously that wasn't the case. Xamarin concentrated on their Mono technology which is an implementation of .NET from Microsoft, but lives in the open source space. Xamarin did try to develop something similar to Silverlight which they called it Moonlight running on Linux. But for some reasons they abandoned it. 


During their course of bringing up new technology features to developers, Xamarin connected different mobile platforms by the means of having a single code base for business logics and data access layer logics using Microsoft's C# language - but never the user interface. When Microsoft introduced Portal Class Library (PCL), they quickly embraced it, and hence, having a common set of API's that sits inside PCL and can be used by many different platforms such as Android, IOS and even Windows Phone. 


This is great news for developers. Especially those who love C# as their favourite programming language. Having to to have a common user interface technology to target different platforms, I guess it's a winner for all developers alike. However, with these great technology advancements on the Xamarin side, comes a cost. Xamarin.Forms does not come in their Starter edition. (see here for details). If you are an indie developer, the best package for you would be the Indie edition which cost around USD299.00. Bummer! A serious developer would certainly sign up for the subscription, but what if you are a developer like me who wishes to find out what the technology can offer before deciding?

To the guys at Xamarin, hopefully you could give us developers some ways to try your out your cool technology... :)

Friday, April 4, 2014

What is "a first chance exception"

I've done some apps that works in a multithreaded environment, and while debugging them, I found out several “first chance exception” was seen at my output window.in Visual Studio. So what is a first chance exception? Is it harmful?


Quoting from a blog on MSDN website.. 

What is a first chance exception?
When an application is being debugged, the debugger gets notified whenever an exception is encountered  At this point, the application is suspended and the debugger decides how to handle the exception. The first pass through this mechanism is called a "first chance" exception. Depending on the debugger's configuration, it will either resume the application and pass the exception on or it will leave the application suspended and enter debug mode. If the application handles the exception, it continues to run normally.
In Visual Studio, you may see a message in the output window that looks like this:
 A first chance exception of type 'System.ApplicationException' occurred in myapp.exe
 In Visual Studio 2005 Beta2, you will see this message anytime a first chance exception is encountered in your application's code.  If you are using Visual Studio .NET 2003, this message is shown if you have configured the debugger to stop when the specific exception type is thrown. If the application does not handle the exception, the debugger is re-notified. This is known as a "second chance" exception. The debugger again suspends the application and determines how to handle this exception. Typically, debuggers are configured to stop on second chance (unhandled) exceptions and debug mode is entered, allowing you to debug. 

Does a first chance exception mean there is a problem in my code? 
First chance exception messages most often do not mean there is a problem in the code. For applications / components which handle exceptions gracefully, first chance exception messages let the developer know that an exceptional situation was encountered and was handled. For code without exception handling, the debugger will receive a second chance exception notification and will stop with a unhandled exception.

Source: from very old article dated 12 Jul 2005 (link)

While, it may not be harmful, it is however, an indication that something wrong happened in your software and may need some extra attention to handle it properly.

Thursday, April 3, 2014

Microsoft Build Event

I didn't realize that last night (MY time) was the starting date for Microsoft's Build event, until I saw in an email notification of mine..

Not in the mood to turn on my PC to watch the keynote, I did it on my Lumia..


Live streaming screenshot taken from my Lumia..


Day 1 saw a hefty load of interesting topics. But I was more keen on "Universal Xaml language and TypeScript.

The former, being a great thing to many win phone developers, we can now target  apps for Windows 8.1 as well.. That's a good thing as you don't need to write two different xaml apps - potentially some tweaking is needed nonetheless. I've blogged before that IOS and Android already have this capability, but for me, coming from a .NET developer point of view, it is something worth waiting for - albeit a bit late in the game.

The latter, on the other hand is something I look forward to see more. What is Typescript?

TypeScript is a free and open source programming language developed by Microsoft. It is a strict superset of JavaScript, and adds optional static typing and class-based object-oriented programming to the language. Anders Hejlsberg, lead architect of C# and creator of Delphi and Turbo Pascal, has worked on development of TypeScript.
reference: wikipedia

I don't know anything about TypeScript although I've heard people talking about it. My bet is it has something to do with javascript and web development... I might just look into it as well in the near future...


I'll write more on this.. so stay tuned..

Saturday, March 29, 2014

Why I chose Windows Phone development for my next big thing...

Why I chose Windows Phone development for my next big thing...

people asked me. My answer is why not? Then they go wining around saying that many softwares comes from Microsoft are crap. Complex software license, damn pricey, and for friends that comes from development background, some say Visual Studio sucks. Its funny though, since almost 80% of my developer friends use Visual Studio day in, day out.

Then I wondered, if Windows sucks, and Visual Studio is buggy, then why are you using it in your day to day work? Why don't you use other platforms... ?! Stop wining peeps! There are always choices out there to choose from. Don't like it? Then switch and move on. No one is forcing you...

Windows is buggy - that I acknowledge, but that was then. I think Windows has come a long way till now. XP was a great product, but Vista wasn't. Win7 is awesome. Win8? Well, it is better in many ways, and not in others. Radical changes especially with the new "Modern UI" language. Its good to see a lot of changes in the new OS, especially moving away from the desktop environment. But too radical isn't good either. On the other hand, unifying the OS platform to become one is a big step ahead and a huge challenge. Something that IOS has accomplished very well several years ago.. - kudos Apple!

Windows Phone is unique. There's no icon to represent apps - Well, the tiles are the "icons". It is different. It lives on top of a concept called Live Tiles. Which I think is a fun to see when those live tiles flips to give me latest information without having to launch an app - It's ALIVE!!!

I know android has something called widgets, but I like live tiles better.

So again, why Windows Phone development? For simple fact is because, I can use C# and xaml to write apps on it. Since I already know WPF and Silverlight, it makes perfect sense to me to jump to Windows Phone app development. Hence, the learning curve was not so steep. MVVM can be applied in almost the same manner as WPF and Silverlight - with some distinctness which I'm not going to talk about here.

The only thing that needs some learning is understanding the wp's application lifecycle, frames and pages, navigation and non linear navigation, transition behaviors from a page to another, backstacks, and so forth. Sounds like its a lot to learn right? Actually it isn't at all. Of course there are some limitations to Windows Phone xaml technology. It doesn't have the power of WPF, but hey, I could create an app with less time. That helps you know...

So my journey started in November 2013. It was the time where I got serious with win phone app development. I joined Nokia's win phone developer's program, and got a year worth of Telerik RadControls for Windows Phone, plus a year worth of Windows Phone Store app account to publish apps. All is good right? No, you need to have a device to test run your app.

Worth mentioning I got myself a Nokia Lumia 920. Proudly to say during that time, I ordered prior to the Nokia Lumia 920 launch in Malaysia!!


Its a piece of awesome device I would say, and I love using it everyday...

From Nov 2013 till now - March 2014, that's like 4 months. I've learned many things in developing an app. Proudly to say, my first test app called Peek-a-boo is already in trial phase at 0.5.0.0. 

Now, I'm coding a new app as well, called Memorizer. More on Memorizer in my future blog post.

In short, within four months of playing around with win phone dev, I've already made a lot of progress. It's only time when I can publish my apps... 


p/s: Apart from Peek-a-boo and Memorizer, I've outlined like 3 or 4 more in the pipeline... 



Full Steam Ahead! 




Tuesday, March 25, 2014

Hello World...

Never in my life wanted to start a blog. I used to write in diaries during my schooling years. Then I stopped because i thought it was time consuming.

Every day my friends urged me to start a blog, in which I did - only after a few attempts at it, then I felt it was useless again.

Time flies like no one's business, and the more I tried to "stop" myself from blogging, the more I realize that I need to.

So here I am. It would be interesting to see what I can write, as I am not a fan of writing down my thoughts.


English is not my first language, so do expect I make mistakes along the way..

Just so you know, I'm Shah Z. S... Shah would be enough to call me. What Z and S stands for? Well, even if I tell you, you most probably can't pronounce it correctly - trust me I know.. :)

Father to a handsome young prince age 4+, and a husband to a very patient wife. Gratitude goes to Allah for granting me a beautiful wife and son.

At work, I'm a full time software developer, at home, I'm a part time software developer, a father and a husband...

C# is the language I know best, although my career started with VB6. So expect me to write about my software development findings in C# language...

It's getting late... time to sleep... till my next post...