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!