DO NOT drive to OSLO in the morning, use train instead, traffic is a hell
Nice, very nice, the morning traffic to Oslo is nothing different than the traffic in Beijing.
Headache, and slow.
Living in a city (OK, OK, it is a town) 20Km far away from Oslo, In the past few weekdays, I got up at around 6:30, and left home at 7, just because of trying to avoid the terrible traffic, however, I still need an hour to reach my office, it is only 20Km!!
CommunicationException was unhandled by user code / There was an error while trying to serialize parameter http://tempuri.org/:serviceList
Error Code:
There was an error while trying to serialize parameter http://tempuri.org/:serviceList. The InnerException message was 'Enum value '0' is invalid for type 'Project.Common.DataContracts.Contract.ContractTypes' and cannot be serialized. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.'. Please see InnerException for more details.
Why:
You are using Windows Communication Foundation (WCF), without WCF, you will not have this issue. This is cased by a serialisation issue introduced by WCF if one of the properties in the object that you were trying to send back to the service is not defined.
Example:
Assume that the ContractType is one of the properties in ObjectType,
====ContractType.cs====
using System.Runtime.Serialization;
namespace Project.Common.DataContracts.Contract
{
[DataContract]
public enum ContractType
{
[EnumMember]
Person = 1,
[EnumMember]
Company = 2
}
}
When trying the send an instance of ObjectType back to the WCF service, all the properties of ObjectType, in this example, ContractType, should be initialized.
For example, if one of the properties in the instance is not initialized, the default value will be set to 0 (zero) if it is an enum type.
In this case, since the ContractType does not contain o (zero), and if you forget to intialize its ContractType, you will receive a similar error above.
Solution:
The solution is pretty simple, just keep a good programming habit, initialize everything before using it, and when defining the properties, the definitions should contain the fallback values, such as "null" and "0" (zero).
Rank: The world's most expensive cities to live in 2009
Currently, at least there are two rank systems that are well-known. One is from UBS and another one is from Mercer.
- About UBS: (Can read more about UBS from this article in Wikipedia)
UBS is a global financial services company, it is headquartered in Zürich, Switzerland. It is the world's largest manager of private wealth assets, "the world's biggest manager of other people's money", and is also the second-largest bank in Europe, by both market capitalisation and profitability.
- About Mercer: (Can read more from Mercer's website)
As it is claimed itself that Mercer is the global leader for trusted HR and related financial advice, products and services, Mercer has more than 18,000 employees serving clients in over 180 cities and 40 countries and territories worldwide.
The Methodologies that used to generate the ranks:
- UBS's Methodology:
USB conducted its standardized Prices and Earnings survey in 73 international cities in March 2009. The data was collected by several independent observers in each city. In all, more than 30,000 data points were included in the analysis. All amounts were converted into a single currency to ensure that the surveyed prices and earnings could be compared. To compensate for daily exchange rate fluctuations, we used the average exchange rate over the data collection period. An international price comparison needs a common, standard basket of goods and services. As in past studies, the basket of goods and services was based on Western European consumer preferences. Living costs were calculated based on a survey of 154 items in total. They include 122 products and services that are used directly to calculate the reference basket. Apartment rents were classified as high-, mid- and low-priced.
- Mercer's Methodology:
Mercer's Cost of Living survey covers 143 cities across six continents and measures the comparative cost of over 200 items in each location, including housing, transport, food, clothing, household goods and entertainment. It is the world’s most comprehensive cost of living survey and is used to help multinational companies and governments determine compensation allowance for their expatriate employees.
In Mercer’s survey, New York is used as the base city for the index and scores 100 points, all cities are compared against New York and currency movements are measured against the US dollar. Tokyo scores 143.7 points and is nearly three times as costly as Johannesburg with an index score of 49.6.
The period from March 2008 to March 2009 has been characterised by an unprecedented economic downturn. The global economic crisis has had a direct impact on the Cost of Living indices in the various locations covered by Mercer, and hence on the resulting Cost of Living rankings.
Ranks in 2009:
- UBS's rank:
2009 2008 Cities 1 2 Oslo 2 6 Zurich 3 4 Copenhagen 4 7 Geneva 5 8 Tokyo 6 5 New York 7 9 Helsinki 8 13 Vienna 9 10 Paris 10 3 Dublin 11 15 Munich 12 40 Caracas 13 16 Frankfurt 14 11 Luxembourg 15 21 Los Angeles 16 12 Stockholm 17 23 Rome 18 28 Lyon 19 34 Dubai 20 19 Brussels 21 1 London 22 26 Barcelona 23 14 Amsterdam 24 38 Singapore 25 18 Chicago 26 22 Madrid 27 30 Berlin 28 35 Hong Kong 29 33 Miami 30 20 Milan 31 24 Toronto 32 25 Montreal 33 43 Tel Aviv 34 29 Istanbul 35 32 Lisbon 36 39 Athens 37 27 Nicosia 38 17 Sydney 39 - Doha 40 47 Ljubljana 41 67 Shanghai 42 42 São Paulo 43 31 Seoul 44 51 Riga 45 36 Auckland 46 49 Taipei 47 52 Manama 48 41 Rio de Janeiro 49 54 Bratislava 50 61 Bangkok 51 50 Prague 52 65 Beijing 53 45 Tallinn 54 59 Vilnius 55 44 Warsaw 56 37 Moscow 57 46 Budapest 58 55 Sofia 59 60 Kiev 60 69 Lima 61 70 Buenos Aires 62 48 Santiago 63 62 Nairobi 64 64 Johannesburg 65 63 Jakarta 66 57 Bogotá 67 53 Bucharest 68 58 Mexico City 69 - Cairo 70 71 Kuala Lumpur 71 66 Manila 72 68 Delhi 73 56 Mumbai
- Mercer's rank:
2009 2008 Cities 1 2 Tokyo 2 11 Osaka 3 1 Moscow 4 8 Geneva 5 6 Hong Kong 6 9 Zurich 7 7 Copenhagen 8 22 New York City 9 20 Beijing 10 13 Singapore 11 10 Milan 12 24 Shangai 13 12 Paris 14 4 Oslo 15 89 Caracas 16 3 London 17 14 Tel Aviv 18 16 Rome 19 21 Helsinki 20 52 Dubai 21 19 Vienna 22 61 Shenzhen 23 55 Los Angeles 23 70 Guangzhou 25 16 Dublin 26 65 Abu Dhabi 27 34 Douala 28 25 Athens 29 25 Amsterdam 30 45 Bratislava 31 89 White Plains 32 30 Lagos 33 74 Tehran 34 51 Abidjan 34 41 Dakar 34 78 San Francisco 37 28 Madrid 38 43 Luxembourg 38 31 Barcelona 40 57 Algiers 41 77 Honolulu 41 39 Brussels 41 80 Beirut 44 44 Almaty 45 75 Miami 46 18 St Petersbourg 47 37 Munich 48 40 Frankfurt 49 38 Berlin 50 84 Chicago
Visual Studio Just In Time Debugger
I was suffering this "Visual Studio Just-In-Time Debugger" for more than a week. Everytime when I close the browser, a window like this pops up, it is so annoying.
I googled this morning and found a solution. Up to now, no pop-ups any more. It seems working fine for my machine, at least.

Here is the reslolution:
1. Open the CMD window, and run this command at the command line:
drwtsn32 -i
After that, you got a pop up window saying that: Dr.Watson has been installed as the default application debugger
2. Then run this command in the command line:
regedit
You will see an application called Registry Editor is opened.
If you are using the 32Bit Windows operating system, you should delete the follow registry keys
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\DbgManagedDebugger
If you are using 64Bit windows operating system, you should delete the following registry keys:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\DbgManagedDebugger
How to access controls in Master Page / Strongly typed Master Page
It is very simple for a page to access the controls in its Master Page.
For example, we can use this way:
((Label)(Master.FindControl(“LblTitle”))).Text = “My Application”;
or
(Master.FindControl(“LblTitle”) as Label).Text = “My Application”;
Can you see that? first, it is not very clean look, second, no intellisence for the LblTitle (the control ID). I don’t like this way of accessing the controls in the Master Page.
I would rather to make the Master Page strongly typed, and create properties or method in the Master Page.
In order to make the Master Page strongly typed, we need to declare the MasterType in the Aspx pages. For example:
<%@ MasterType virtualpath="~/MasterPages/Support.Master" %>
Some Google Android PDF books, nothing much, just for the sake of developers
PLEASE, DO NOT blame or curse me if you really really hate piracy stuff.
I am just a normal developer, only want to share something that I have. If you really concern, please let me know, I will remove it from my blog.
There are only three Google Android Ebooks (in PDF format) that currently I have, will keep adding more in this post, if I am not annoying anyone.
Thanks!
Hello Android Introducing Google's Mobile Development Platform - Ed Burnette
Beginning Android - Mark L. Murphy - Apress
Pro Android - Sayed Y. Hashimi and Satya Komatineni - Apress
Disable the history in the TextBox field / disable the AutoComplete for TextBox
When you want type in something in the TextBox field, It is very annoying that sometimes a long history is shown, besides, it is not secure at all, cause the others when using this computer that have the chance to see what you have typed in before.
Sure you want your application has such a drawback and annoys your application users? There are some ways to work around, you can either disable it using JavaScript, or disable it in the code-behind, or set the control property in the Aspx page.
If using JavaScript:
<script type="text/javascript">
function disableTextBoxHistory(id){
_obj = document.getElementById(id);
if (_obj != null && _obj != undefined){
_obj.setAttribute("autocomplete", "off");
return true;
}
else
return false;
}
</script>
If in the code-behind:
TextBox1.Attributes.Add("autocomplete", "off");
In in the Aspx page:
<asp:TextBox ID="TextBox2" AutoCompleteType="Disabled" runat="server" />
Why the history is shown? There are several reasons:
- The AutoComplete Setting is turned on by default in some browsers,
- The ID of the TextBox that shows the history is the same with the one in some pages before you have visited where you have typed in some texts.
What is the solution:
I don't have any good ways of solving it. Acutally, we can not touch the client side broswers to disable this AutoComplete setting. A not-so-smart way is to generate a random control id for the control on the fly.
Disable users goto previous pages
Due to security reasons or some other reasons, we don’t want the users have the ability to go back to previous pages (by clicking the Back button in the browser). It is impossible to disable the Back button directly, thus we have to do something in the code.
There are at least two ways of disabling the users to goto previous pages. One is using JavaScript in the client side, another one is to set the pages that have already expired in the server-side.
In the client side:
<script type="text/javascript">
function noBack(){
window.history.forward();
}
noBack();
window.onload = noBack;
window.onpageshow = function(evt) { if (evt.persisted) noBack(); }
</script>
In the server side:
protected void Page_Init(object sender, EventArgs e)
{
Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
}
The way of using JavaScript in the client side has a drawback. This cannot really forbid the users go back to previous pages when the JavaScript function is disabled in the browser side.