Recently I took a brief tour of PowerShell, it’s the Microsoft’s task automation framework. It would suit you more if you consider your keyboard as your friend :). At the moment, I do not know whether I think it is useful or not. I think the more I get to know the various commands, the more I will use and appreciate it.
I am writing this post, so that I can record the PowerShell commands that I begin to use. Here’s is the first one:
Get a new GUID: Currently I use Visual Studio 2005 to get a new GUID value. Now opening up VS just to do that is really an overkill.
In PowerShell we can get it by:
[guid] is a type adapter (you can say alias) to the full class name – System.Guid. NewGuid() is a static method on that class.
If we don’t remember the adapter but if we do know the full class name, we can use –> $guid = [System.Guid]::NewGuid()
Monday, 14 January 2013
Windows PowerShell - Get new GUID
Wednesday, 5 December 2012
Uninstall problems – solved by Microsoft Fixit
Many times, I think very frequently, we face problem with uninstalling a software. This happens on our development machine where we many times install/uninstall software, sometimes clearing the local MSI cache, uninstalling patches and of course registry corruption – all making it a nightmare when we simply want to uninstall by going to Control Panel – Add/Remove Programs.
Now here is one thing that can help:
Microsoft Fix It:
http://support.microsoft.com/mats/Program_Install_and_Uninstall
Also a link from Apple:
http://support.apple.com/kb/TS3704
Recently we had an issue with uninstalling a software which was looking for MSI file and telling “The feature you are trying to install is on a network resource that is unavailable”. We ran this tool and it fixed the registry. The software causing the problem is no longer listed in the “Installed Programs” list in Add/Remove Programs.
Screenshots from the tool:
Edit: Clicking ‘Accept’ in the screenshot above actually downloads the tool and at times there is difficulty in connecting – could be because of proxy issues or Microsoft server was down perhaps.
Wednesday, 14 November 2012
Microsoft’s patent application for cloud compilation
This is a link which will take you to the patent application from Microsoft for its new compilation in the cloud service for Windows Phone 8 apps.
http://www.freepatentsonline.com/20110258616.pdf
It’s for the first time that I am reading a patent application. I never knew the technical details given were so exhaustive and in-depth. In fact it could be turned into a book.
More details:
http://www.zdnet.com/microsoft-details-its-strategy-for-compiling-windows-phone-apps-in-the-cloud-7000007185/
http://channel9.msdn.com/Events/Build/2012/3-005
Sunday, 28 October 2012
Bing.com analyzes .NET 4.5
The link above will take you to a blog post from Windows Server team. BIng.com recently migrated to Windows Server 2012 and .NET Framework 4.5. I like the way they use performance counters to monitor their application. The Event Tracing for Windows mechanism also looks promising.
The runtime improvements in .NET 4.5 can be found here: link
Sunday, 14 October 2012
Finally .NET boots out Windows XP
.NET 4.0 required XP with SP3 and now .NET 4.5 doesn’t support it at all.
So it’s build once and run only on last two released operating systems - Vista and Win 7 :-)
ASP.NET MVC Certification
So finally we have a certification on ASP.NET MVC. Microsoft recently released this exam 70-486: http://www.microsoft.com/learning/en/us/exam.aspx?id=70-486
I plan to clear it by December 2012 and now there is second shot offer too from Prometric. Here is what I am watching to refresh things a little bit - http://www.asp.net/mvc/pluralsight
Second shot link - http://www.microsoft.com/learning/en/us/offers/secondshot.aspx
Tuesday, 18 September 2012
Platform Guidance from Telerik
In short: for the desktop it is WPF, for Win 8 Xaml/C# and for rest ASP.NET MVC.
Although the cloud (Azure) is missing, the choices are quite simple for a Microsoft developer these days :-)
Monday, 23 July 2012
UI: Good setup interface
Friday, 20 July 2012
70-511 Windows App Dev Certification
The exam is a tough one covering almost all the topics with sufficient depth.
How did I prepare?
- I took a hard look at the 'skills measured' or the exam objectives to find out what I knew well and what I didn't.
- Bought these two books:
WPF 4 Unleashed and MSPress Self-Paced Training Kit
- WPF Unleashed I basically read almost from cover to cover, except few topics like 3D and easing functions (3d is not in exam but easing function is, I just didn't have time in the end to cover easing functions)
- MSPress book also I went through all chapters.
- But these things would not matter if you don't have experience of at least 1.5-2 years of developing real world WPF applications.
Benefits:
I have certainly gained a deep understanding of the technology and appreciate it a lot more now. There are few things that I did not know, for instance animation classes are really easy and wonderful to use. In my job, coding in WPF has become a lot more 'flowy', now there are no apprehensions/doubt about how some parts of the framework work.
Tuesday, 10 July 2012
WPF: View Model Communication
Recently we had a requirement in our project to establish communication between two view models.
The user interface design and their data context values:
The ‘User Control 1” (UC1) has a grid showing the list of business products and ‘User Control 2’ (UC2) a grid with categories of products. The categories and products can be added/removed/changed by the user.
We had a business case that – if the category is removed by the user on UC2 then what should happen to the products on UC1 which are using that category? It was decided to delete those products and it should happen automatically – that is the deletion of category should trigger the deletion of product from the list.
The model contains the observable collection of Products and Categories and bound to the grids on the UI. The categories are deleted with the help of button in one of the columns, this button is connected to a DeleteCommand in the UC2 view model which deletes the selected category from the list.
So how can we “do something” on the products view model when something happens on categories’? What are the options?
- Attach to the Categories collection changed event.
- Pass the product view model to the categories so that categories can call some method like Changed() on product’s view model
- Or we could also let the Categories view model go ahead and delete the product from the Model itself thus automatically reflecting on the product’s grid.
You can see there are problems with all these options – the first two create tight coupling between the view models. And the last one doesn’t couple but does something more terrible – changing the Model that it doesn’t own. It is not meaningful or intuitive for a view model to change a Model class which it does not use on its bound UI and more importantly it violates the single responsibility principle (SRP).
However there is an elegant solution. MVVM Foundation (a framework) offers a Messenger class which facilitates view model communication. It uses Mediator pattern so that there is minimum dependency. Let’s see the code.
1. First a static class which can be used by all the view models.
public static class ViewModelCommunication
{
static ViewModelCommunication()
{
Messaging = new Messenger();
}
//a singleton object for view model communication
public static Messenger Messaging { get; set; }
//list of messages
public static string CategoriesChanged { get { return "CategoriesChanged"; } }
}
We create a “ViewModelCommunication” class which is a static class with a static constructor which initializes the “Messenger”. Also we create a static property for “CategoriesChanged” which can be used by any module to register for this message or raise this message. Additional messages could be added for other message types.
2. Next we modify Product view model to register for notification
ViewModelCommunication.Messaging.Register(ViewModelCommunication.CategoriesChanged, (Action)
delegate()
{
Refresh();
}
);
We use the “Register” method on Messenger class to register our message – CategoriesChanged and assign a delegate to be called whenever such message is received. In our code, the ‘Refresh()’ method would be called whenever the user changes a category.
3. Categories view model raises the alert
//notify messaging colleagues
ViewModelCommunication.Messaging.NotifyColleagues(ViewModelCommunication.CategoriesChanged);
The Categories view model sends notification whenever its own Categories collection changes.
And we are done!
Avoiding Memory leaks
One internal detail – the Messenger class uses a sub-class of WeakReference so that the memory is not leaked (link). Otherwise in our example, let’s say Categories and Products show up on a different windows which can be closed. So when the Products window is closed, the Messaging class will still maintain a reference to it as it points to the delegate – thereby product’s view model would not be GC’ed leading to memory leaks. Using WeakReference solves this problem.
Shorts - week 3, 2022
Post with links to what I am reading: 1. A very good post on different aspects of system architecture: https://lethain.com/introduction-to-a...
-
Let’s look at another often used control in business applications – TreeView. It is a great control to visualise hierarchical data. Take an ...
-
Many times we use delegates such as Action<T> or Func<T, TResult> and we do not want to pass in any argument. For instance, let’...