C# 5.0 – Caller Information

C# 5.0 has some new features which can aid us in debugging and logging.

Take a look at this code below on how we do logging prior to C# 5.0. Here we have the need of logging the details of the call made to MethodB()

1 class Program 2 { 3 static void Main(string[] args) 4 { 5 InsertToLog("Main"); 6 MethodB(); 7 MethodA(); 8 9 Console.ReadKey(); 10 } 11 12 private static void MethodA() 13 { 14 InsertToLog("MethodA"); 15 MethodB(); 16 } 17 18 private static void MethodB() 19 { 20 } 21 22 private static void InsertToLog(string methodName) 23 { 24 Console.WriteLine("{0} called MethodB at {1} ", methodName, DateTime.Now); 25 } 26 }

In the above code all the methods who call the MethodB() has to make a call to InsertToLog(string methodName). This has 2 major problems.

1) Code repetition

2) Very easily one can miss a call (simply forget to call InsertToLog)

So it would be nice to have the InsertToLog method inside MethodB and if we can pass the caller information to MethodB.

C# 5.0 has this feature. Look at the code below.

1 class Program 2 { 3 static void Main(string[] args) 4 { 5 //InsertToLog("Main"); 6 MethodB(); 7 MethodA(); 8 9 Console.ReadKey(); 10 } 11 12 private static void MethodA() 13 { 14 //InsertToLog("MethodA"); 15 MethodB(); 16 } 17 18 private static void MethodB( 19 [CallerMemberName] string memberName = "", 20 [CallerFilePath] string filepath = "", 21 [CallerLineNumber] int linenumber = 0) 22 { 23 InsertToLog(memberName,filepath,linenumber); 24 } 25 26 private static void InsertToLog(string methodName, string filepath, int linenumber) 27 { 28 Console.WriteLine("{0} called MethodB at {1} from {2} on line number {3}", methodName, DateTime.Now,filepath,linenumber); 29 } 30 }

In order to use the caller information you have add the following reference.

 

using System.Runtime.CompilerServices;

SQL Configuration Manager WMI Error–Remote Procedure call failed [0x800706be]

 

I got the above error in the SQL Configuration Manager and googled for a solution. Unfortunately first few links were not satisfying, then I tried with some extra effort and found these details.

My box is running on Win 7 x64 and SQL Server 2008.

It is said that this error can occur in 2008 R2 as well. This is due to some bug or flaw in the installation process. I tried reinstalling the entire SQL Server Engine again I got the same error. Read the following forum discussion for more details.

http://social.msdn.microsoft.com/Forums/en-US/sqltools/thread/569ee2d4-0805-40e2-a4f0-10f7d573fd75/

Then I found another option of restoring the assemblies, using the command line. I tried that as well, but again I failed. Here’s the image of the executed command in CMD. Click the image to enlarge.

image

Now I’m in the process of upgrading my SQL Server 2008 to SP3. I can’t update it to 2008 R2 due to some project constraints.

Still I don’t know what is the exact reason for this issue.

Page.FindControl(string id)

 

Hi, if you have searched for the problem, Page.FindControl(string id) raises a NullException in ASP.NET then you came to the right place.

The answer is simple

try the following…

Control c = this.Page.Master.FindControl(“ContentPlaceHolderID”);

c.FindControl(“The ID of the control you search for”);

 

Read the below link for the detailed information

http://forums.asp.net/t/1000865.aspx/1

Introducing MS PixelSense Technology

 

Surface..Surface..Surface. Every where you can see this. The biggest game changer from MS with Windows 8, Metro and all other great stuff.

But wait, we heard of surface computing from MS. A huge table which can do amazing stuff. I wrote an article about how to develop Surface computing applications as well. Here’s the link.

So what happened to that Samsung SUR 40 and other Surface computing devices ? because now every body talks about the surface of this.

The answer is available in the same link. Just scroll down and look at the bottom left corner of the above link. There you get PixelSense  and the link to visit the PixelSense web page.

They did it very silently because very few were aware of the surface computing which is now the PixelSense. I don’t know why they chose the name ‘surface’ for the metro devices, but they finalized it and changed the old surface into PixelSense.

I don’t know whether there was a public announcement about this change in the name, but they did it. So now I can say myself as PixelSense developer. 😀 cool…

Retirement of Microsoft Certifications

 

Microsoft certifications are subject to retirement when the specific version of a technology expires or outdated. This time MS comes with loads of new technologies and they have announced set certifications to be expired soon.

The following link has the list of all the certifications which were already expired and the ones to be expired soon.

http://www.microsoft.com/learning/en/us/certification/cert-lifecycle.aspx

Facebook ✔ seen 01:58

 

You might have noticed that recently FB added a new feature in the chat to show whether the other party you are chatting with have seen the messages you send or not. This is a cool feature for some extent as long as I can check whether my friends have seen the message I send. But same theory applies to me as well. I personally do not like this much.

There are plenty of other ways to avoid a person in FB. Simply I can make myself offline to that particular person. But let’s discuss about something really wobbly about this feature.

Technically speaking this seen feature can be implemented in many ways. And also a real question I have in my mind is ( and FB did it in a very sneaky way) to know whether FB assures that the other person read it or not. The answer is No.

I tested few scenarios of this ‘seen’ feature.

The rule of thumb is, FB detects the seen when and only if your browser tab on which FB is loaded and the chat window of a particular chat are open and in focus.

Simple.

And FB says whether the user has seen the message or not. It doesn’t say anything about whether the user has read the message. Because FB sends the seen acknowledgement to the other party approximately after 8 – 9 seconds from the time it got the focus event fired. In some cases this time is very short; something between 1 – 3 seconds. But it doesn’t bother about the length of the message whether the message can be read in 10 seconds or not. So it just says the users has simply seen the message. It makes perfect sense.

In Windows 7 we can hover the taskbar icons and get the full snap of the windows we have opened. From the OS perspective this is not focus. This applies to FB as well. Because technically in FB this feature works on Javascript focus events which get the focus signal from the browser, where the browser get the triggers from some sort of a system call from the OS.

So you can use this method to read the messages without getting caught. 🙂 but this is not always possible and easy.

Imagine Cup 2012 – Srilanka

The team I lead won the Microsoft Imagine Cup 2012 local finals in Srilanka in software design category, and now we are expecting to show the colors in Sydney in the world finals.

No need to tell much about the Imagine Cup since it is one of the most famous and prestigious technology competition hosted world wide by Microsoft to solve or support the toughest problems that the world has been facing for decades; which are also addressed by the United Nations as their Millennium Development Goals. More Info : http://www.imaginecup.com

When considering the Imagine Cup and myself I have 2 years of experience with Imagine Cup. In 2011 also, I competed under software design category with a difference group lead by one of my friend and our solution got the 2nd runners up in the local finals. This time I was invited by my few other friends to join and lead the team.

I joined them and we created a solution which can creatively support the sustainable development of the country. Our solution is simply and carefully crafted to be developed on top of already available technologies such as Facebook and mobile phones. This gained a massive reach to our solution.

I’m very happy that my team won the Imagine Cup, I personally feel very happy about that we brought the Imagine Cup to the Faculty of Information Technology after 4 years.

We hope that we’ll do our best in the world finals.

Windows Phone SDK in Windows Server 2008 R2

I have been using WS2K R2 in main primary laptop for last 5 months. I wanted to install the Windows Phone SDK on my server. Then I got the error that WP SDK is not compatible with the Server OS. I googled and finally found this useful link.

http://blogs.msdn.com/b/astebner/archive/2010/05/02/10005980.aspx

If you have an offine WP 7 installer like an ISO file extract them using any file compressing tool and follow the steps mentioned in the above link.

But another pain point is Zune does not support on the server OS. Don’t worry .. I did the search again found this following link.

http://robmensching.com/blog/posts/2009/9/12/How-to-install-Zune-software-on-Windows-2008-R2

Personally I didn’t check the Zune install on Windows Server 2008. So if it is not working don’t blame me, I just believe the Google 🙂