find a location for property in a new city

Friday, 6 January 2012

How to run Crystal Reports on Azure

Here is a step by step guide on how to make an ASP.NET project that uses Crystal Reports run successfully on Azure. If you try to run a Crystal Report in your ASP.NET site without the Crystal Reports runtime installed you will receive a "System.Runtime.InteropServices.COMException" with description "The Report Application Server failed".

The problem is that you need to install the Crystal Reports runtime. This isn't a problem with regular hosting since you can just install Crystal Reports on each of your servers and off you go.

With Azure, though, if you remote into the machine and install it, it will work fine until your deployment is redistributed to another machine which it will do at some point due to the nature of cloud computing.

How to install Crystal Reports on your Azure web role

Fortunately it is still easy with Azure. Easy when you know how anyway. Here are the steps you will need to take:

First of all you will need to download the SAP Crystal Reports runtime engine for .NET Framework 4 (64-bit). This should extract as a msi file called CRRuntime_64bit_13_0_2.msi.

In your web application in Visual Studio you should paste this msi file at the route of your web project and include it in the project. Right click it in the Solution Explorer and set its 'Build Action' to 'None' and also set its 'Copy to Output Directory' to 'Always Copy'.

Next you will create a command file to execute this msi file. Create a new text file, call it StartUp.cmd and then save it in the root of your web project (next to the msi). In that file write the following:

@ECHO off

ECHO "Starting CrystalReports Installation" >> log.txt
msiexec.exe /I "CRRuntime_64bit_13_0_2.msi" /qn
ECHO "Completed CrystalReports Installation" >> log.txt

Set the properties of StartUp.cmd to 'Build Action' = 'None' and 'Copy to Output Directory' = 'Always Copy'.

Now in your ServiceDefinition.csdef make this cmd file a start up task by adding the following lines:

<WebRole name="Web" vmsize="Small">
    <Task commandLine="StartUp.cmd" executionContext="elevated" taskType="background" />

You are now instructing each instance that starts up with your package to run the Crystal Reports msi file that installs the runtime on the instance ready for its use in Azure.

A few Crystal Reports on Azure tips

I ran into a few bits and bobs which caused me unnecessary pain along the seemingly clean process outlined above. I will share them with you in case you do too in no particular order.

  • Make sure your .rpt Crystal Report files are set to Build Action: Content and Copy to Output Directory: Copy always.
  • Don't be alarmed with how long it takes to deploy. It will take much longer to upload than usual because you are now uploading an extra 77MB of installation files. It took me an hour to deploy on my home connection!
  • Ignore all the warnings about how your web project is dependent on various Crystal Report assemblies since Azure will have them just as soon as your installation file runs.
  • Configure a remote desktop connection when you do your deployments since it will be invaluable should anything go wrong and at an hour per deployment you don't want to be messing about.
  • Visual Studio may have added a load of random assemblies in your web.config you are not aware of and don't need and may even cause problems like log4net.

That is all. Good luck - it's very satisfying when you get it going.

Follow britishdev on Twitter


  1. I followed this along with partial success, but that's probably a version thing [it's now May 2012].

    My Azure webrole is on an x64 server, and I'm developing in vs2010, with .Net 4.0. Crystal runtime is up to 13.0.3.

    The big issue is the 'undefined bobj' error, which I think is being caused because IIS is installed on D: on the Azure server. Does Crystal look for the viewer on C:?

    My work around, if it helps, was found here

    Bascially copy all the viewer files from the aspnet_client\system_web\4_0_30319 to a sub-directory of your project, fill in the sections in your web.config as shown in the link above, and it works.

    1. Great Article Cloud Computing Projects

      Networking Projects

      Final Year Projects for CSE

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. Great instruction, all works. But I have one problem: I have a report with dynamic parameter and from local computer I have a list of items from combo box. But when I upload it to Azure and I view report, I have to enter value to textbox (like in static parameter).

    I connect to Azure database.

  3. Nice article, and I have implemented the same as you posted, but i am unable to publish to Azure.
    I am getting the below error when I click on Publish

    Error 64 Exception of type 'System.OutOfMemoryException' was thrown. C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\Windows Azure Tools\1.7\Microsoft.WindowsAzure.targets 2814 5 WindowsAzure1

    Can you help on this?

  4. this way is good one to install crystall reports but it akes too much time .
    alternatively we can use .bat file and powershell to run crystal reports on azure
    it is very fast ,whole procedure is finished in 20 minutes.

  5. Hi!!
    Can you show me the way to do it with a .bt and powershell?
    May be it's posible to host the engine into a Blob and create an Script to download it and install it, but I don't know how.

  6. Hi, I uploaded to Windows Azure a WebSite that uses Crystal Reports.

    I'm not using a Virtual Machine, but a "Standard Web Site". Is this tutorial specific for virtual Machine? If it isn't, where "ServiceDefinition.csdef" comes from??


    1. Dear Jaime,

      Did you get any solutions to this? I am stuck with the same scenario.

    2. Hi Usman,

      Sorry for the delay.

      I endup using a cloud service following those steps.
      "ServiceDefinition.csdef" comes from the Azure project you have to include to your solution.

      Hope this helps.


    3. OK thanks, i will look into it and will try to implement.


  7. Hi Colin, I moved to Cloud Servive and followed your steps, but it crash with log4net.dll: “Could not load file or assembly ‘log4net’ or one of its dependencies.”, and log4net is not included in my web.config.

    Did you face this problem?


  8. Hi Colin,

    We have deployed crystal reports on azure web roles. We are facing following issues:

    1. We have noticed that whenever the web roles cloud service restarts(for any unknown reason), the crystal reports installation doesn’t work and the cloud service just goes into loop of starting and restarting, and our web application doesn’t work at all. The error we get is: : Could not load file or assembly 'CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The way we fix this problem is by logging remotely into the instance and manually installing crystal reports. After that our web application works fine.
    2. The biggest advantage of web roles is that we can have multiple instances. But we have noticed that the moment we have more than one instance, sometimes crystal reports work and sometimes it doesn’t. What happens is sometimes when it doesn’t work we see cross image indicating image not found. But if we have only one instance then no problems, crystal reports works fine. But then we cannot take full advantage of azure web roles multiple instances capability.

    Any help/suggestion much appreciated

  9. I have spent complete 2 days and now almost fedup. Is this solution not valid for mvc web app which is currently working fine on Azure. I added one view which is returning pdf version of crystal report. I am unable to run. Can run startup.cmd file. As i can only use webjobs. Is there any way i can run .msi file in my web app on Azure? Your help will be highly appriciated. Thanks

    1. Did you get a solution? We are trying to run a MVC Project and we have the issue on create a ReportDocument(), the error is "log2net.dll could not be loaded".

    2. I did not get log2net.dll related error. On Azure, i was having issue with crystal reports. I am still struggling with it. Just got one answer today (see above comments) will try to implement that solutions. If it works, will share with you.

  10. Hi Usman, if your using free trial version in window Azure then your not able to installmsiexec.exe /I "CRRuntime_64bit_13_0_2.msi" /qn but if your paid version then once you install msiexec.exe then you won't get Error, you can able to view report.

  11. Hi
    I am getting logon failed, however I can connect to SQL server through SSMS , and the rest of site.

    Any ideas

  12. This comment has been removed by the author.

  13. This comment has been removed by the author.

  14. After deployed in azure, we get this error :

    System.TypeInitializationException: The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception. ---> System.TypeInitializationException: The type initializer for 'CrystalDecisions.Shared.SharedUtils' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'log4net, Version=, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.
    at CrystalDecisions.Shared.SharedUtils..cctor()
    --- End of inner exception stack trace ---
    at CrystalDecisions.Shared.SharedUtils.get_CurrentControl()
    at CrystalDecisions.Shared.SharedUtils.GetEffectiveCulture()
    at CrystalDecisions.CrystalReports.Engine.CREngineRes.GetString(String name)
    at CrystalDecisions.CrystalReports.Engine.ReportDocument.CheckForCrystalReportsRuntime()
    at CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor()
    --- End of inner exception stack trace ---
    at CrystalDecisions.CrystalReports.Engine.ReportDocument..ctor()
    at AzureCrystal.Controllers.HomeController.PrintReport()

  15. Ok the issue was the 64 bit. I had to use the 32 bit to get rid of the log4net error

  16. hi, ?I am getting the following error after sometime..

    The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Bearer error="invalid_token", error_description="A security token validation error occured for the received JWT token."'.

  17. hii. i want to use crystal report in app services in azure then how to use

  18. This comment has been removed by the author.

  19. I'm browsing the Internet to get information and find your blog. I am impressed with the information you have on this blog.

  20. Wholesale printed custom perfume boxes with the highest quality and affordable prices. Free worldwide Delivery and free Custom Perfume Boxes design.

  21. Buy online wholesale custom eyeshadow palette packaging and packaging at seashore packaging at the easy price Free shipping worldwide with 24/7 customer support.

  22. Buy online wholesale printed candle boxes and packaging at easy prices and shipping worldwide, with 24/7 customer support. Get a free custom quote now!!

  23. Blackbird packaging provide you with any size, shape design, cbd boxes sooner than any other packaging competitor in the market

  24. Blackbird packaging provide you with any size, shape design, lipstick boxes sooner than any other packaging competitor in the market

  25. Pacakaging town is a one stop solution for the short-run cbd facial oil boxes needs and supplies. At affordable prices. Request a free quote now.