Tuesday, September 2, 2014

Not running in a hosted service or the Development Fabric

Runtime Exception:
Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

{"Not running in a hosted service or the Development Fabric."}

Fix:
I accidentally had set the Web Role project as the startup project. Setting the cloud service project in the solution as the Startup project helped me get past this exception.

Metaprogramming with T4

Recently, I learnt how to generate code using T4 text templates. The requirement was to read data from a CSV file and create in-memory objects based on the data representation in the CSV file. So if my CSV file had records with 4 columns, the code had to read the file and create in-memory objects such that each object has 4 fields mapped to the 4 columns. There were multiple CSV files of different record types and manually creating a class for each record type was tedious. After doing commonality/variability analysis, it was apparent that I could use T4 to generate the CSV file reader for each record type by reading metadata about the CSV file.
As my understanding of T4 evolves, I will share my learning here. For reference, posting some good links that provide some guidelines on code generation and when to use it.

Code Generation good or evil
Code Generation Pros and Cons of T4 template
MSDN Code Generation and T4 templates

What is success?

The journey of life takes us through varied experiences like landing an admission at a prestigious college, earning a degree, getting hired,...