Monday, 14 June 2010

Everyday Enterprise Architecture - The book - full download

It appears that Tom has put the full version of his new book for download for a limited period of time. Check out if it is still available here

Note: though the page might say its a preview edition, its actually the full book.

Monday, 10 May 2010

Review - Book - CLR via C# 3rd Edition by Jeffrey Richter

Having been a die hard fan of the second edition of CLR via C#, couldn't wait to get hold of the third edition. The third edition keeps up to the Jeffrey standard on covering from the basics to the internals of .NET 4.0 with C# 4.0. Starting with the rather interesting foreword by his wife, this book can be read end to end if you are already comfortable with .NET and have enough time to read through ~850 pages of pure core stuff.

There is so much of deep insight in most of the pages that it might take some time to absorb stuff. The best recommendation to attack this book is to read one chapter a day while preparing notes. Once you are done with the book, your notes together with the book can be one hell of a reference at any point. If there is only one book you read as a .NET developer, this is it. Even if you have been the best .NET developer of your league, each time you read this book there is something new learnt. This book covers a good wide area of .NET topics, sometimes delving deep too.


Sharing Richter's deep experience and know-how of .NET in plain non-geeky language has worked out well. Additionally, there are various tips and notes provided in the boxes and shaded text that are pure gems. Richter has made sure that the reader is thoroughly introduced to CLR concepts and in turn how things work out from the C# layer to the IL layer. Richter had made sure that most discussed basic stuff like hashcodes, interface v/s class, explicit v/s implicit interface definitions are discussed to a level such that no further questions arise. There are various instances where he has provided guidance on what to use and why, while sometimes providing historical background to these decisions.

There is good introduction to advanced topics like application domains in the context of hosting. With multicore and concurrency the talk of the town, new to 3rd edition are the 5 new chapters dedicated to discussion on threads and related classes in .NET. Discussion on TPL, PLINQ, spinning and locking etc are dealt quite thoroughly.

At the end of the book you would feel a better .NET developer, ready to take on your next development task in a more elegant manner - believe me.

Tuesday, 23 March 2010

Setting Physical Memory Limit for a .NET application

We needed to limit the physical memory used by a .NET application as it was taking too much of it and the other apps appeared to be in a struggle mode.

The straightforward way appeared to use Process.GetCurrentProcess().MaxWorkingSet. Strangely, no matter what we tried, this never worked. Yet to figure out why it does not work - if anyone has a clue, please ping.

Anyways, looking at options we came across job objects in Windows that allow setting the max working set. So the approach that finally worked was this:

1.) Create a Job object using CreateJobObject() Win32 call

2.) Setup the memory limits against this job using
SetInformationJobObject()


3.) Assign our process to this job using AssignProcessToJob().

Now, when we look at the task manager, the physical memory assigned to this process never goes over the specified limit. All good.

Note that this is applicable only for the physical memory and not for the virtual memory - no limits can be set for this [?]. The physical memory limit is affected when the application is paged-in from the page file into the memory.

Thursday, 18 March 2010

Exploiting ObjectFromLresult() to get the IHTMLDocument2 from a window handle

Assume you have a window handle to a html control (which implements IHTMLDocument2) within a browser page (which is an IWebBrowser2), how would you access the HTML elements?

This is interesting as with just a window handle, it was relatively unknown on how that can be mapped to an object.

What you need to do is this:

1.) Register the windows message WM_HTML_GETOBJECT

2.) Send this message to the window handle we have in hand using a SendMessageTimeOut(). The out parameter in the lpdwResult returns you an UIntPtr to the object after the call.

3.) Next, use this out parameter as part of the ObjectFromLresult() call:
ObjectFromLresult(result from sendmessagetimeout, IHtmlDocument, 0)


4.) Cast the result from ObjectFromLresult() to IHTMLDocument2.

5.) Use the all property to get the HTML elements.

The powerfull function here definitely is the ObjectFromLResult() which effectively returns you an object that is 'accessible'. Accessible in terms of the user accessibility factor.

A framework worth checking out in this regard is the UIA framework that allows manipulating individual entities on the screen be it winforms, browser controls...

Wednesday, 24 February 2010

Azure Computing Usage, Metering etc and how MS gets richer

As per the MS release, the azure usage is to be calculated based on the 'compute instance'. $0.12 per hour it appears is for the 'small compute' instance size. For others, multiply this by the number of CPUs as per the below image :







Caveats

Based on your requirement, you could go for the small/medium/Large/Extra Large instance size. Things sound good until we dig a bit deeper on this. There are a couple of weird bits about the compute metering:

1.) If your application instance has 10 roles (worker/web...), each role would add up to the hrs!

Eg: - if you have 10 roles active simultaneously for 1 hr, you are charged for 10hrs.

2.) There is no part calculation. Even if you had you application active in Azure for 5mins and you delete it , you would end up paying charge for 1 hr!. This also is effective for the roles:

Eg: - if you have 10 roles active simultaneously for 5minutes, you are charged for 10hrs (yes, 10hrs)

3.) The compute usage is not determined by the actual computing/processing usage. Say even if your role/instance is idle for 50mins in the 1 hr, you are still charged for 1hr! This means that as soon as you have your application deployed, you get billed - immaterial of its computing usage.


Simplifying it down, your usage charge for a month = Number of roles in your instance * 24 (hrs in a day) * 31 (days in a month) * Subscription-factor.


Where, Subscription-factor = 1 for small, 2 for Medium,4 for Large , 8 for Extra large.


4.) Another interesting bit is about the alignment with the hours - it appears if you deploy your application at 3:50pm, you would have to pay an additional hours charge (2pm-3pm, 3pm-4pm).


5.) Are you a developer? There is no developer account/scheme wherein you could test out your application in Azure for free, yet.


Anything that adds to the MS revenue is good (for them).




Update 15.05.2010
For the various queries raised in this regard to the Azure support team, the answers from them haven't been direct, but rather confusing. Please do not rely on this post for deducing the cost, but contact the Azure team directly.


Quickly calculate Azure ROI/TCO

Interested in quickly calculating the ROI/TCO for your application once it is deployed in Azure? Check out these two:

1.) http://www.microsoft.com/windowsazure/tco/

2.) http://neudesic.cloudapp.net/azureroi.aspx

View/Query tables/data in Azure Dev Storage

When deploying application on the development fabric, you would usually need to actually view the dev storage - say check out the tables, write a couple of SQLs against it etc. OOB, there isn’t any support in VS2010/tools from MS. Note that development fabric is different from the Azure Storage in the cloud. Development fabric, dev storage resides on your local machine.

A very good tool you could use to access the dev storage for free (in addition to the azure store if you are a registered user) is Cloud Storage Studio from Cerebrata. Check more here:

http://www.cerebrata.com/Products/CloudStorageStudio/Default.aspx

Do let know if you come across any more free/thin/sleek/nifty tool that works.