Skip to main content


Showing posts from 2010

Curious case of PDF file not being included as part of deployment

I included a PDF file as a part of web project and hyperlinked it in a page. This web application was part of Azure deployment. When I tried to test this in the dev fabric to my surprise i was greeted with 404 error :(
I turned out while VS does some magic for web content files (html, asp, jpg etc), but for PDF file it does not set the Build Action property of the file and hence this error. Changing the Build Action to 'Content' solved everything.

Happy Coding,

Integrate ELMAH with WCF and Azure

I recently integrated ELMAH (Error Logging Modules and Handlers) with our Azure application. ELMAH is an excellent error logging and reporting libary available for ASP.Net. We used ELMAH for logging all unhandled service exceptions in WCF and ASP.Net. While there is information available on internet about how to integrate these technologies, data is scattered in bits and pieces. My aim through this blog post is to details the steps required for integration.

The scenario of usage is, we wanted to log all unhandled exception thrown by our WCF service layer in a database which in our case was SQL Azure. Once done we could easily navigate to the the elmah default url to get a nice report on what errors were being generated by the application. Had it been a typical ASP.Net application, integrating ELMAH is a piece of cake. But since we were working on a Azure web deployment with SQL Azure as the backend some tweaks were necessary. Here are the things to do to get ELMAH fully functional in …

What i learned today.

Working with ASP.Net and SilverLight in my current project i learned two important things today
SL will always show generic NotFound exception for a remote call failures irrespective of what was returned from server. This limitation roots in the browser which does not pass the exception details to the SL plugin. The only way around is to always send a responses which have Fault property for the SL client to work with. ASP.Net forms authentication mechanism always redirects on 404 error and behaviour is hard to change. This becomes a problem working with SL or ASP.Net MVC clients which expect Http error code (REST clients). The workaround that i found on Stackoverflow was to thrown 403 Error Code instead of 401. This way service calls made from SL or ASP.Net MVC can return http status codes (REST endpoints) and will not cause server redirects.

Encoding\Escaping special characters in Silverlight

I spend almost half an hour to find how to do encoding\escaping special characters in SL. Started with SecurityElement to HttpUtility etc but none were available in SL. Well as it is with google, if you ask correctly you would be rewarded. Turns out that there is a class in System.Windows.Browser assembly for SL that contains HttpUtility class. Checkout here
If i had just type HttpUtility in the IDE i could have got it :(
Anyhow, Happy Coding.

PartitionKey Used in Windows Azure Diagnostics Trace Listener

In case you are wondering what partition key does Azure Diagnostics Trace Listeners add to Azure tables. It is combination of 0 + Current DateTime Ticks
Hope this helps you querying the Azure Storage for diagnostics data.
Do check this awesome link that describes way to connect to Azure Storage using LinqPad and retrieve diagnostic information.
Happy Coding

Windows Azure: Automated Commandline Deployment woes

I was trying to automate the process of Azure deployment through command line. The Azure Powershell cmdlets make this job very easy.

I was facing some issues when deploying the Application on Azure using commandline( using CSPack + Azure cmdlets). Some of the features on the site were functioning, specifically those that depended upon Azure configuration files. The same worked with VS 2010 package and deployment.

I realized that the package I was creating with CSPack was different from what VS 2010 was creating.

The first step i took was to reproduce the issue on Dev Fabric.
I was luck enough to reproduce the same issue in Dev Fabric if i deployed the package file created using CSPack.
What i realized was that the WebRole class which should be called by framework whenever the Azure Framework initializes was not being called for some strange reason. I had called some initialization code such as SetConfigurationSettingPublisher in WebRole.cs.
This was causing call made later to fail.
I did som…

Adobe Acrobat Activex Control issues with 64bit machines. Error "Class not registered HRESULT 0x80040154..."

I justed moved from a 32 bit laptop to a 64 bit laptop. The project we are working on uses Acrobat Reader activex control to show PDF documents. When I ran the project on my system from VS 2008 the application threw exception while trying to load the PDF viewer control. The error returned was
"Class not registered HRESULT 0x80040154..."
The issue turned out to be that the solution was compiled for "Any CPU"\x64 bit architecture. Once i changed the build configuration to x86 and recompiled the error was resolved. It intially seemed like the component was not installed correctly and i tried to reinstall Acrobat Reader multiple times before hitting the correct solution.

Happy Coding

Default Namespace and Attributes

This is what i learned today

Default namespaces do not apply to attributes; therefore, to apply a namespace to an attribute the attribute must be explicitly qualified.

Must remember this. Can be very helpful while debugging XML schema issues.


Debugging databinding failures in WPF

WPF has a great databinding support but when it does not work it can be hard to debug. Understanding of databinding model in WPF can go a long way in making data binding easy. Since working on WPF i myself have faced "binding not working" syndrome. The general tendency then is to revert back to the code behind approach which does not look clean at all. In all cases its our lack of understanding of binding model or incorrect usage of binding the main culprit. In this post i would try to create a checklist which can be used to systematically debug any specific binding issue. But before reading this i would highly recommend that every WPF developer should thoroughly try to understand the WPF binding by going over the MSDN documentation and other sources. The steps mentioned here would make more sense if we have a clear understanding of databinding. We would be tacking the most common situation where a frontend UI is bounded to a backing entity.

Is the binding setup correctly (B…