Monday, August 23, 2010

Fully Qualified Type Name in Silverlight

You can ignore the Culture and PublicKey, and they will be defaulted to "neutral" and "null" respectively. However, you must have the following three components in order for Type.GetType(typename) to return you the correct type (otherwise, you will get a Null/Nothing, which is very frustrating).
1. FullName (Namespace + Class name, etc. Complicated when it is a nested class, or generic class, etc.)
2. Assembly
3. Version
An example is:
"DMS.RuleEditor.ViewModel.Logical, RuleEditorViewModel, Version=1.0.0.0"

Find out position of an UIElement in Silverlight

Use GeneralTransform to get the position of the UI Element:

1 GeneralTransform objGeneralTransform = myObj.TransformToVisual(Application.Current.RootVisual as UIElement);
2 Point point = objGeneralTransform.Transform(new Point(0, 0));
3 double myObjTop = point.Y;
4 double myObjLeft = point.X;

Monday, August 2, 2010

Generic.xaml in Silverlight 4

After much pain and suffering, :), I found that the Generic.xaml has to be put under Themes folder for it to work in Silverlight 4. It makes sense... but the postings on the internet are not helping. Some say it must be under the root folder, and others only addressing WPF. Am I the only person trying to do a custom control in SL4?

Friday, June 25, 2010

Mysterious connection trouble on Intel WiFi Link 1000 BGN

I experienced a mysterious connection trouble on my Windows 7 laptop in the last two days. The symptom is a very slow and unstable connection. Since I had encountered similar problems on other computers before, I assumed it is a spyware infection. This specific machine has the Microsoft Essentials anti-virus that I am not trusting much. However, the frustration continues as I just can not connect to internet or home network and download anything large. At the end, I resorted to downloading to another home computer and used wired connection on this machine to get the file running. It took some effort (probably because I had WiFi and Wire on at the same time) but finally finished.
After I run Spybot S&D: Surprise! I have zero problems!
Not even a tracking cookie? At this point, I started wondering if my previous assumption was all wrong. I tried "ping -t" to my local router and found the connection is not stable at all, at it drops the ping every once a while. Then I suddenly realized, upon looking at the connection properties, that I changed some settings on the wireless card for my new Wireless-N network. And surely, it turns out that the "Throughput Enhancement" in Advanced was turned to "Enabled". After I set it back to "Disabled", the connection is back to normal.
This is a lesson that I have unlearned multiple times. And I am sure I will unlearn it again in the future: Always jog down the changes that you are making, especially if you don't know what it really means...

Thursday, April 22, 2010

"Only models that include foreign key information are supported." error in Entity Framework 4

This is an error I encountered in EF4 within Visual Studio 2010, when I use the "Model First" approach and created a database from a theoretical model. Ironically it will not compile after that because of the error. Microsoft still has a lot of work to do here.

Solution:
1. Create the property within the entity for the FK using the same name.
2. In mapping details, map the new property to the underlying table field.
3. Select the original association and click the Referential Constraint and choose the right principal and dependent.
4. Now select the association again, you will see a message akin to "Mapping not allowed for exposed foreign key... Delete the mapping...".
5. Click on Delete the mapping link.
6. Recompile.
Viola! World peace...

Wednesday, August 6, 2008

Central or Distributed social structures?

This post maybe a little confusing but allow me to elaborate. There are two topics that seemingly unrelated to many people, but somehow connected in my mind. The two topics are:
1. Are we going to cloud-based computing? Or, is computing becoming a utility?
2. Solar-cells on every rooftop?
Once I list them down here, you can immediately see the seemingly different directions these two things are going. For cloud-based computing, people's computing need, word-processing, spreadsheet, database, etc., is going to a centralized facility that provides all the functionality for an as-needed base. But for Solar-cells, it is going to a de-centralized direction, making every house-hold a self-sufficient cell in the society.
Which brings the question: Is there a certain direction for any human society to go for its basic needs? I think Computing should be considered a basic need now, at least for developed countries, while power has been considered as such for a long long time.
Human history has shown that people have becoming more and more interdependent on a larger and larger scale. Back in the agriculture society, every household is self-sufficient. Each home can provide all the needs itself, from wheat and rise on the table to clothes on the body. And that's why a siege to a city can last for years without a result (think about Troy). Not in the current time, when a batch of salmonella infected tomatoes brings panic to literally the whole country of the United States. The reason here, most economists can tell you, is because of trade.
Trade can, almost always, make both parties better off. It is taught as an axiom of economy in any universities. It also brings inter-dependencies that people argue makes the society more stable. For example, if you are in substantial trade with another country, then it makes you think twice or more times before you start a war. And thus people, especially the western developed countries, believes the more trade, brings more inter-dependencies, the better.
However, I want to argue that there is a fallacy to this, as it is not eliminating all the chances of conflicts and/or disruptions to the society. On the contrary, it makes the potential conflicts bigger, and/or disruptions more disruptive. It may not be a good thing after all.
An analogy would be made with earthquakes. If there are small earthquakes on a fault line, the pressure of the earth plates got released often, and the chance of having a major one is slim. However, if there is no small releases of the pressure, the chance of getting a devastating one becomes larger. Same thing to societies. If there are small conflicts all the time, then the chance of a big one got reduced. But currently, because of all the inter-dependencies we have, there is no release of pressure within the system. And once we have a big conflict, then it will spread easily across the connections and bring down the whole system in a whiff.
Which brings my point: Maybe global trading is not such a good deal, anyways. And we should have roof-top based solar-cells, just in case.

Friday, June 13, 2008

"Job description like" resumes are sure killers

I am just going through some resumes for my colleagues open position and am surprised at those "Job description like" ones. What I meant is that the resume looks like a copy of the job description of the titles that he/she had. They are full of things such as "Performed developer functions involving scope requirements, systems analysis, design development, documentation, software development, testing, implementation, and maintenance.", or "Developed applications in support of Level 3 operations, Business Partners requirements, and other special projects.".
I would say that this is the worst possible resume that you can make. It doesn't give any useful information for the hiring manager about what you can do and what you have done. Unless you were a dummy, nobody should fail to meet the above "Job Descriptions". But the problem with this is that it also shows that you have nothing to say about your previous/current job. A useful resume should list the Accomplishments front and center in all the jobs you have. And the explaination of the accomplishment can tell potential hiring managers about the level of success that you had. Absent that, one can only guess that the reason you didn't put any accomplishments was because, simple, you didn't have any.
These resumes really give me goose-bumps. I'd better go back and check mine...