Technology trends you should know

After getting positive feedback on : https://kiranpatils.wordpress.com/2011/09/29/why-we-need-windows-communication-foundation/
https://sitecorebasics.wordpress.com/2015/04/04/sitecore-multisite-basics/
Thought to spend sometime to write a new comic on Technology trend! So, If you would like to learn about Latest technology trend then  this article is for you
Before you go further I would like to mention that this article would have not been possible without this article from Tess : https://blogs.msdn.microsoft.com/tess/2015/11/12/mastering-asp-net-5-without-growing-a-beard/
So. If you liked this article then the credit goes to her and NOT me. Because I just converted those learnings in comic — So, you enjoy reading it!
Let’s go!
In a small town there used to be a guy. Who was very had working. His name was Mr.Earner he was very busy in his project and personal life (like you!) and when one fine evening he was reading about latest technology trend. He felt that he left behind the technology trend. So, he went to church and prayed to Jesus for showing him path!
As always Jesus listens him and guides him to talk to Mr. Learner — Mr. Learner is a famous in town for his knowledge and knowledge sharing skills.
TT1
TT2
TT3
TT4
TT5
TT6
TT7
TT8
Keep learning, Keep Sharing!
Happy Coding! 🙂

Future Unleashed India 2015 Experience

Luckily, Along with my troop got a chance to be present at Future Unleashed India 2015. Would like to share my experience with them who can’t make it happen or who would like to have a quick recap of it!
It was held at Nesco convention center at Mumbai on 5th and 6th November 2015. On 5th there was a business track (Where Mr. Nadella and lot of big names of Indian IT Industry attended and presented) and on 6th there was a technical track.
Full agenda can is here : http://futureunleashed.microsoft.com/default.aspx
I’ve been able to be part of Technical Day and keen to share that experience with all of you!
But before that will share my registration experience. It was just awesome, Microsoft team kept calling and we were in sync with all latest and greatest details. And on the event day as well. Whole process was super simplified — And would like to say thanks for all the teams for being so helpful and co-operative!

My notes from Technical tracks which I’ve been able to attend:

Keynote by Scott G.

Before keynote started the musical performance was awesome, and it recharged the whole environment!
It was great to see Scott in person. He shared few important updates:

  • Now, Azure is in 24 Regions around the world!
  • Azure is unique platform which support On premise setup as well as Cloud setup
  • Azure it opening 2/3 Data Centers in India
  • Quick demo of creating new VM and publishing stuff from Visual studio
  • Quick demo or Power BI as well
  • He also called few partners to share their learnings with audience. It was great to hear their experience!

Building Modern Web App with ASP.NET 5 and VS 2015

  • Great session by Mr. Chetan Vaja
  • He demonstrated capabilities of ASP.NET 5
    • Few big changes
      • You can host your ASP.NET Website without IIS — On Console — Self hosted
      • Can be hosted on Linux and Mac as well — He demoed it!
      • Has Built in DI
      • Everything is modular
      • For web forms you have to use 4.6
      • It uses Roslyn compiler. Which means you no need to build your change and wait for a long time. Just do a change and do F5 on browser — More like PHP Experience
    • Got integration like
      • grunt
      • gulp
      • bower
  • DNX = Dotnet execution environment
  • Kestrel : New open source linux server
  • Good to read links: docs.asp.net

Continuous Testing

  • Awesome session by Mr. Atin Bansal – Senior Program Manager
  • Demo of IntelliTest : Using which you Visual studio can create all possible test cases automatically. And you can save them as .CS file – As of now it works with Public methods only
  • Cool things with VSO – Visual Studio Online
  • Load testing on VSO and VS 2015 : Covers all scenarios I know. But you need to have VS Enterprise license and ready to pay for VSO load testing
  • Manual testing — Test cases addition and execution support

IOT From Scratch

  • There will be 25 B connected Gadgets by 2020 [Source : Gartner]
  • Grove PI +
  • Full demo : Where PI sent data, Azure was receiving data, and using Power BI we can analyze that data!

Technical Debt with TFS and SonarQube

  1. Good session by Harysh Menon
  2. MS is working on integrating it with SonarQube
  3. So, you can see Technical Debt and can do quality releases!

As of now have to install it using Zip. But they are working on making installer

Neo4j – The graph DB

  • Good session by BrijRaj Singh
  • Nicely explained
  • Graph DB Concept
  • We had few demos

Overall the event was awesome! Microsoft took very good care of us. Everything was just perfect. Would like to give my gratitude to the whole team — And I thought doing it via blog post will be the best way to do it!
Waiting for the next one..!

References:

http://futureunleashed.microsoft.com

Cleanup failed to process the following paths

Challenge:

One fine day, while doing SVN Cleanup. We faced following error:
Cleanup failed to process the following paths:
<PATH>
Previous operation has not finished. If it was interrupted
Please execute the ‘Cleanup’ command.
You are also facing similar challenge? Then you are at the right place.

Solution:

  1. Open command prompt
  2. Type TortoiseProc.exe /command:cleanup /path: /closeonend:0

That’s it!

Error while using Cascading DropDownList with AjaxControlToolkit

Challenge:

While Implementing Cascading drop down we faced following error:
Error: Error: Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument.  Event validation is enabled using in configuration or <%@ Page EnableEventValidation=”true” %> in a page.
For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.
If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Source File: http://OURHOSTNAME/ScriptResource.axd?d=3VKrK_7HFd3y9jouIWGfT0xsPUpPWsWH7SoDffy51nkCL04Nc90n7Ein_H4RztbD1yDGLUI-Zz15U7kAewqh2RASTjlbBKaWvjs5uaWOHUtXwDXAq22ilJZaUX8Iu9W_HK9ITwo1waG12DLEuDRxogn2m-XmlhYYCX-66L12c6NnjBet1rAqn3G588BxLbc40&t=348b0da
Line: 1534
Yes, you are right. Our DropDownLists were wrapped within Update Panel. You are also facing similar error? Then this post is for you:

Solution:

We did a quick search and found following links:
http://ajaxcontroltoolkit.codeplex.com/workitem/8103
http://forums.asp.net/t/1903036.aspx?how+to+set+EnableEventValidation+false+from+userControl+DotNetNuke
From Link what we understood is that, It is a BUG of AjaxControlToolkit and to resolve  this you’ve to try following workaround:
[sourcecode language=”csharp”]
protected void Page_Init(object sender, EventArgs e)<br clear="none" />        {        <br clear="none" />            Page.EnableEventValidation = false;<br clear="none" />        }
[/sourcecode]
So, Just use this code where you are facing this challenge. We were seeing it from one of the Sublayout. So, we kept it there and it worked!
Happy Coding! 🙂

XML XSLT Namespace gotcha

Challenge:

Before couple of weeks back we spent a good amount of time making XML and XSLT work, you must be thinking so easy then why this guy invested lot of time. Wait o minute coming to you.

Solution:

Basically, we had XML and we were trying to fetch few nodes via XSLT from it. But it was not working as expected. We verified everything our XPATH was correct and everything was correct then following link, pointed us towards a solution:
http://stackoverflow.com/questions/1730875/xslt-transform-xml-with-namespaces
Our XML was having xmlns deceleration,  and we were not using xmlns in our XSLT document. And that was the reason why XSLT was not able to XPATH nodes. Once, we added XMLNS to our XSLT document and changed our XPATH as per XMLNS then everything started working as expected!

Fast and furious way to LoadXML document

Challenge:

While loading XMLDocument using LoadXML method we found that sometimes it takes a long time to load xml. Is is a same challenge you are facing? Then this post is for you!

Solution:

http://codinglight.blogspot.in/2009/06/how-to-load-xmldocument-and-completely.html
This article helped us to do so! Basically, when you hit LoadXml Method it, internally validates XML by loading it’s DTD — and if your DTD server is busy it may take time to load.
So, the solution (If it is not breaking your functionality) is set XmlReaderSetting’s — Set XmlResolver to null, and ProhibitDtd to false.
That’s it!
Happy XML Loading! 🙂

Thread synchronization basics!

Challenge:

My dear readers, happy new year to all of you! Sorry for being away from you since so long. But no worries. I’m back with new post — means a new thing to share with you!
Before few months back, was reading on .NET Locking mechanism. During that period learnt a lot. So, this post is to share it with you!

Solution:

So,  here we go:
1.  To clear your threading basics, I would recommend MCTS 70-536 book!
2.  Few best links, from the web:
http://www.aspnet101.com/2010/03/50-tips-to-boost-asp-net-performance-part-i/ [Tip#11]
http://msdn.microsoft.com/en-us/library/1c9txz50.aspx
http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx — lock basics! — I loved this example!
“lock (this) is a problem if the instance can be accessed publicly.” — So, if your class is public, Don’t use lock(this) else whole class will get locked by one thread and other threads will keep on waiting for it.
“Best practice is to define a private object to lock on, or a private static object variable to protect data common to all instances.”
http://msdn.microsoft.com/en-us/library/system.collections.hashtable.synchronized.aspx — For syncing
http://thevalerios.net/matt/2008/09/using-readerwriterlockslim/ — Good to know “Under the hood, the lock statement is just syntactic sugar for Monitor.Enter() and Monitor.Exit().If you really want to see for yourself, write a simple lock statement like the one below and open the compiled assembly in Reflector, then look at the IL (not the C#, since Reflector automatically recognizes the underlying lock syntax) — you’ll see calls to [mscorlib]System.Threading.Monitor::Enter and [mscorlib]System.Threading.Monitor::Exit surrounding the code inside.”

While it is a good thing that only one operation can happen to the shared state at any given time, it can also be a bad thing. The whole purpose of the lock is to prevent the corruption of the shared state, so we obviously don’t want to be reading and writing at the same time — but what if two threads are only trying to read at the same time? That’s pretty harmless, right? Nothing can get corrupted if we’re just reading.
In light of this, the lock statement is too cautious and certainly not optimal. Imagine a scenario with 1 thread writing and 10 threads reading — if we use the lock statement then each of the 10 reading threads must execute exclusively when they could be interleaved, leading to inefficient use of resources and wasted effort.
http://msdn.microsoft.com/en-us/library/system.threading.readerwriterlockslim%28v=vs.90%29.aspx — New mechanism in .NET 3.5!
http://kenegozi.com/blog/2010/08/15/readerwriterlockslim-vs-lock
http://blogs.msdn.com/b/pedram/archive/2007/10/07/a-performance-comparison-of-readerwriterlockslim-with-readerwriterlock.aspx
http://www.heikniemi.net/hardcoded/2009/12/readerwriterlockslim-performance/
http://stackoverflow.com/questions/407238/readerwriterlockslim-vs-monitor
“For write-only load the Monitor is cheaper than ReaderWriterLockSlim, however, if you simulate read + write load where read is much greater than write, then ReaderWriterLockSlim should out perform Monitor.”
http://stackoverflow.com/questions/4217398/when-is-readerwriterlockslim-better-than-a-simple-lock
http://stackoverflow.com/questions/59590/lock-keyword-in-c-sharp
http://forums.asp.net/t/1765023.aspx/1
http://jachman.wordpress.com/2006/08/02/best-practices-readerwriterlock/
HashTable is thread-safe if “Hashtable is thread safe for use by multiple reader threads and a single writing thread. It is thread safe for multi-thread use when only one of the threads perform write (update) operations, which allows for lock-free reads provided that the writers are serialized to the Hashtable.” [Source : http://msdn.microsoft.com/en-us/library/system.collections.hashtable.aspx]
Happy Threading and Safe locking! 🙂

Export to Excel/CSV doesnt work on IE under SSL (https)

Challenge:

We’ve one functionality where user can save CSV/Excel file. Which was working fine in all browsers when we check it via HTTP. But it doesn’t work under IE when we do it via HTTPS.

Solution:

Cause:
1. If your page is passing caching header – Response.AddHeader(“Cache-Control”, “no-cache”);
2. And having export to CSV/Excel — Via Response.Write code.
Then it will not work in IE6/7/8 — This KB article says that this issue is fixed in IE9 — http://support.microsoft.com/kb/323308
OR remove no-cache control header from your page. But it is also required to have it as you might not want to save sensitive pages on client side. And if you remove no-cache header then it will save sensitive pages on client side. Isn’t it a real fix? Don’t worry we have a solution for you!
We googled it and found following link:
http://aspnettechstuffs.blogspot.in/2010/05/export-to-excel-does-not-work-in-ssl.html
Which worked for us in IIS 6.0 But not in IIS 7.5. Also, we wanted to avoid IIS specific changes and wanted to fix it from code. So, it doesn’t affect full functionality and only affects related modules.
We added following line in top of our export to CSV/excel method:
Response.ClearHeaders();
// Following by Export to Excel and Response attribute’s logic
And it did a trick!
Happy Coding! 🙂

Good to read:

http://stackoverflow.com/questions/4672073/export-to-excel-doesnt-work-on-ie-under-ssl-https

Basics of Memory leak

Challenge:

Before couple of weeks, we wanted to check whether our application has memory leaks issue or not? And while doing that we found few articles, understood something, and learnt something which I would like to share with you.

Solution:

Best links to read:
http://www.codeproject.com/Articles/42721/Best-Practices-No-5-Detecting-NET-application-memo
http://blogs.msdn.com/b/tess/archive/2005/11/25/496899.aspx
Basically, to detect Memory leak you should check following things:
You should check if Private Bytes/Bytes in all heaps/Virtual bytes increase at the same rate. If you don’t see growing of private bytes, so it means no any memory leak is happening!
Expert comments from Ekaterina — Genius person on this earth who helped us to understand this issue (God bless Ekaterina and Tess!):
Generation 0:
This counter displays the number of times the generation 0 objects (youngest; most recently allocated) are garbage collected (Gen 0 GC) since the start of the application.So when this number becomes higher over the time, it is OK. It just should grow at steady pace.
if you create a simple program, that will create in cycle a lot of large objects and put them to some archive (this will be not really a memory leak however you’ll get an OOM). In this case private bytes and bytes in all heaps will grow at the
same rate, and this can be treated as excessive memory consuming in managed code.
Also I noticed that when you have this memory problem, number of GC collection is also jumping and growing high very quickly – because new large portions of memory should be allocated fast, so I also pay attention to GC behavior.
Happy Coding! 🙂

DataSet Vs Custom Entities

Challenge:

Dear Readers, Apologize for not sharing anything with you since so long. As was bit busy with projects. (But as I told in my earlier posts as well, It’s good to be busy. Because during your busy time you will learn a lot, and needless to say once you get time you will have a lot to share!)
This week, We were discussing what to use for our new project for passing data from one layer to another layer. DataSet Or Entities.
I’m big fan of Entities and Generics. But thought to do some research on it, before concluding anything. And my research revealed that I’m (I know you as well) not only one who is searching on this topic. Lot of people shared their views on web. But I filtered out few links, which I liked most (along-with the Excerpt which is important to read from that link)  and thought to share with you! So, here you go
http://forums.asp.net/t/1129497.aspx/1
“The problem with DataSets is that they tend to be pretty memory hungry. They also get a bit difficult to manage as your application gets larger. When you need more complex solutions, the initial effort that you put into getting custom classes up and running can pay off with shorter development cycles if you do it right. “
Going with custom classes is certainly better in many ways.
i) easier to add logic
ii) business validation is easier. This is tougher when using DataSet
iii) if you are using DataSet, even when the number of rows returned are small, the whole dataset has to be constructed which is quite an overhead. Custom classes are more light-weight
http://codebetter.com/jefferypalermo/2005/05/20/displaying-aggregates-dataset-vs-domain-object-performance-level-300/
“The page that used an array of custom domain objects to present a read-only display was 3.7% FASTER than the same functionality using a DataSet. “
http://blogs.msdn.com/b/reinouth/archive/2006/03/08/546510.aspx
“Now, amazingly, this has sparked somewhat of a religious war between various parties within the project. Just to be clear – I prefer custom objects – partly for their simplicity and readability”
“I agree with you on custom objects, you will have more control and better performance.”
http://blogs.msdn.com/b/irenak/archive/2006/02/27/539832.aspx

  • Memory consumption using Dataset = 290,436 (3.5 times larger than using Products class)
  • Memory consumption using array of objects = 140,028 (1.7 times larger than using Products class)
  • Memory consumption using Product class = 82,656 (BEST)

So, no matter how you turn it, strongly typed custom classes are your best bet in terms of memory consumption!
http://weblogs.asp.net/paolopia/articles/dsvscustomentities.aspx
2) BIZ and DAL are written by people different from the presentation layer group, so they have different knowledge about the data structures
http://www.4guysfromrolla.com/articles/051805-1.aspx
While DataSets are an easy way to return data, I think they are less than ideal for a couple of reasons. First, they add a lot of bloat to the returned XML payload since DataSets return not only the data they contain but also the data’s schema.
In my original article one of my main thrusts for not using DataSets was the performance disparity between DataSets and DataReaders. As I cited from A Speed Freak’s Guide to Retrieving Data in ADO.NET, when bringing in several hundred or thousands of records, a DataSet can take several seconds to be populated, where as a DataReader still boasts sub-second response times. Of course, these comparisons against several hundred to several thousand records are moot if you are working with a much smaller set of data, say just 10 to 50 records in total. For these smaller sized result sets, the DataSet will only cost you less than a second (although the DataReader still is, percentage-wise, much more efficient).
http://swap.wordpress.com/2007/07/10/dataset-vs-custom-entity/
Benefit with Custom Entity Classes
– Take advantage of OO techniques such as inheritance and encapsulation
– You can add custom behavior
– Object-Relational Mapping
– Mapping Custom Collections
– Managing Relationships between two entities in Object oriented way
http://stackoverflow.com/questions/1679064/should-i-use-entity-framework-dataset-or-custom-classes
I would agree with Marc G. 100% – DataSets suck, especially in a WCF scenario (they add a lot of overhead for handling in-memory data manipulation) – don’t use those. They’re okay for beginners and two-tier desktop apps on a small-scale maybe – but I wouldn’t use them in a serious, professional app.
http://www.rosscode.com/blog/index.php?title=datasets_vs_custom_objects&more=1&c=1&tb=1&pb=1

Solution:

So, in summary, as per my understanding, performance, maintainability, and serialization point of view entities looks more promising than DataSet.
Few of my guidelines:
You should use DataSet when:
1. Project is small.
2. Only Single person is going to work on all layers.
3. Data size is small.
4. Application is not going to get changed in future. (Mainly Database structure).
5. You are not worried about Maintainability.
You should use Custom Entities when:
1. Project is big.
2. Different people will be working on different layers.
3. Data size is big.
4. Application is going to get changed in future. (Mainly Database structure).
5. You are worried about Maintainability.
6. If you love to follow OOPs concepts.
These all are my views, and they might look biased toward Entities. Because as i told earlier, I’m big fan of custom entities. But if you would like to use DataSet and have good reasons to use it. Don’t worry go for it!
Happy Coding! 🙂