none
Excel Automation hangs up when running shapes.addpicture RRS feed

  • Question

  • I have a very frustrating issue.  I have an MVC application which downloads some database information, including a potential image, into an excel file (server side) and returns the file to the user.  I recently read that excel automation isn't necessarily recommended or supported, but this is way after I developed my solution.

    It works perfectly when ran from my dev machine (windows 7 32 bit VS 2013), and it also works great when run from my test server (Windows Server 2008 R2 - Excel runs under NETWORK SERVICE).  However, when i try to run the code on the production server (Windows Server 2012 R2 Datacenter), the excel automation service that launches hangs up on the Excel.Shapes.AddPicture line.  

    I've tried everything I can think of to fix the issue:

    Ran the application pool under an admin account

    added code to force the service to display itself in case there were model message boxes (this did NOT display the excel app..., however it DID display in test and dev)

    created a macro to perform the AddPicture routine.  Failed in production but worked in test and dev

    I found that VBA wasn't installed correctly on the server.  I corrected this, though i suppose it's possible that an error remains that is causing the issue.

    search through DCOMCNFG and changed a few settings.

    Can anyone suggest something to investigate as far as why the excel service won't appear when I run .visible = true, or why the service hangs up when I run Shapes.AddPicture?  Any direction would be wonderful.

    Thanks all

    Tuesday, April 4, 2017 7:46 PM

All replies

  • Hi Guitar Maestro,

    first of all , I want to inform you that it is not recommended by Microsoft to use Office interop on server side to automate the Office Application.

    Considerations for server-side Automation of Office

    and you already know about this as you had mentioned in your original post.

    it will work unexpectedly, on some versions you will find that it is working correctly but on other versions it is not working.

    same in your case, on your test server  (Windows Server 2008 R2) it is working fine but on your production server (Windows Server 2012 R2 Datacenter) it is not working. because it is not designed to work with servers.

    so better thing is you need to use other approaches that can support server side automation.

    you can try to use Open XML. then you not need to install MS Office on server. it can work without that.

    also you can try to use some third party Api services or DLLs.

    Aspose.Cells for .NET

    other option is that make your production server configuration same as your development and test server.

    when you develop something then you always need to take care that your development machine and your production machine are configured same. so you will not face this type of issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 5, 2017 1:35 AM
    Moderator