-1

It's about ASP.NET Web App that doing simple Visio Office Automation- convert file from vsdx to svg.

I already know thet it's not recommended to do it on server side from the Microsoft documantation MS. But, only Visio convert my complicated diagrams correct (the Aspose also wrong convert).

The App works well on my PC(windows 10 Enterprise) by any way, from VS when launch as IISExpress/Project/Executable/IIS and even from the IIS itself. But, on the server(Windows Server 2019 Standard) the App works well only when i run it as exe from the cmd but throw an error (message: "An exception occurred". with no any more usefull info) from the IIS in the following point:

using Visio = Microsoft.Office.Interop.Visio;
Visio.InvisibleApp visioInvisibleApp = null;
...
Visio.Document doc = visioInvisibleApp.Documents.Open(vsdxSourcePath);

What could be the difference and how can I cause it to work on IIS?

Please note that it's a little bit different from all others question on this issue in the fact that it's already works well on IIS on my PC and only dont works well on the Server.

  • Does this answer your question? [MS Word Document Operations are not working with IIS](https://stackoverflow.com/questions/9889362/ms-word-document-operations-are-not-working-with-iis) – GSerg Aug 03 '21 at 19:51
  • 1
    Does this answer your question? [Open doc file is null IIS 7.5](https://stackoverflow.com/q/17135233/11683) – GSerg Aug 03 '21 at 19:53
  • 1
    @GSerg Thanks but those dont answer my main question. – Gal Tzemach1 Aug 03 '21 at 20:53
  • 1
    The mostly likely difference is the user account (and associated permissions) running the code. IIS has quite complicated rules about what user account is used, and the defaults on a server are different than a workstation. It could also be the way `vsdxSourcePath` is determined or resolved on the server vs the workstation. – Joel Coehoorn Aug 03 '21 at 21:55
  • “ it's already works well on IIS on my PC” is a useless claim. Something not supported by Microsoft (not recommended in its common terms) is doomed to break in most of the cases you wanted. – Lex Li Aug 03 '21 at 22:13
  • 1
    @LexLi, I understand what you are saying, but still the fact that it works on one machine is a some of proof that it can be run on another machine as well. In addiotion, in my case there is no other options because only Visio converts my diagrams correctly. – Gal Tzemach1 Aug 03 '21 at 22:34
  • 1
    I'm not sure if you have noticed Joel Coehoorn's comment. But what he pointed out is very possible. When you use cmd, the application is executed with the permissions of the currently logged in user. But IIS is "application pool identity" with very low authority. So have you changed the identity of application pool? – Bruce Zhang Aug 04 '21 at 06:30
  • 1
    @JoelCoehoorn & BruceZhang, This can definitely be the direction. But, on both the PC and the server I changed the Identity of the Application Pool to my user (of course is administrator). Is there another place that can change / determine the identity of the user running the code? – Gal Tzemach1 Aug 04 '21 at 09:25
  • 1
    What is the issue? the IIS or the ASP.NET Core? ANP.NET Framework could be fine? – Gal Tzemach1 Aug 04 '21 at 14:17
  • 1
    What about the credential of authentication?https://i.stack.imgur.com/jcaBB.png – Bruce Zhang Aug 05 '21 at 08:19
  • 1
    @BruceZhang, Which level in IIS you talking about machine/site? and what should be there? – Gal Tzemach1 Aug 05 '21 at 08:39
  • 1
    In site level. Did you try to set it as administrator or give ISUR the permission of read and write? – Bruce Zhang Aug 05 '21 at 08:40
  • 1
    @BruceZhang, I changed the identity in the Application pool level from the defaulte one to my user(admin). Now, per your ask, i tried also to change the identity in the Site level from IUSR to my user. But, the same error. – Gal Tzemach1 Aug 05 '21 at 10:39
  • 1
    Is the version of Visio installed on your machine and on server the same (i.e. 32/64 bit)? – Nikolay Aug 05 '21 at 11:08
  • 1
    @Nikolay, Same on both, Visio 2016 32-bit. – Gal Tzemach1 Aug 05 '21 at 14:44
  • 1
    Are you running Visio (under IIS) from your account on both machines? If not, I would try that. – Nikolay Aug 05 '21 at 18:29
  • 1
    @Nikolay, I'm logged in with the same account on the both Visio. What do you meaning under IIS? You meaning to the identity of the Application Pool? – Gal Tzemach1 Aug 08 '21 at 16:18
  • 1
    Yes, I mean IIS :) Make sure your code runs under your account in IIS. You can configure the account under which the code is executed. Just make sure it's your account. Typically you set the application pool identity, That should work unless you have already changed something else (you can tell IIS NOT to use pool identity if you change it directly in the APP, or use impersonation - there are options). So Just make sure IIS uses YOUR account to open Visio. – Nikolay Aug 08 '21 at 19:33
  • 1
    @Nikolay, I'm just changed the identity to my user in the Application Pool in the IIS. I didn't changed this configuration in other location. Anyway, how can I make sure that IIS uses my account to open Visio? – Gal Tzemach1 Aug 09 '21 at 18:04
  • 1
    I regret to tell you that after my discussion with Microsoft, this is indeed not possible through IIS.https://support.microsoft.com/en-us/topic/considerations-for-server-side-automation-of-office-48bcfe93-8a89-47f1-0bce-017433ad79e2 – Bruce Zhang Aug 17 '21 at 05:59
  • 1
    @BruceZhang, it's not possible or not recommended? Can you please extend a little bit what can't work and why? The IIS itself blocks the access to the office app (Visio)? – Gal Tzemach1 Aug 17 '21 at 07:50
  • 1
    It is not possible and not recommened. It isnot IIS block the access to the office app. Office may exhibit unstable behavior and/or deadlock when Office is run in ASP, ASP.NET, DCOM, and NT Services. And these applications run on IIS. So it is blocked by those application. – Bruce Zhang Aug 17 '21 at 08:15
  • 1
    @BruceZhang, It's not fully currect.. because on my PC it's works well from the IIS! (the issue occured only on the server) so it's possible. Regarding the issue on the server, if I will create a service that do the convert and start him from the Web API? – Gal Tzemach1 Aug 17 '21 at 12:26

1 Answers1

1

Finally! Just should grant a permissiom, by: Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Visio 2003-2010 Drawing

  1. Right Click
  2. Properties
  3. In Security tab -> Change from "Use Default" to "Customized" in all 3 option.
  4. In Identity tab -> Change to "This user" option and fill your details.
  5. Apply & OK

Now the Office App (Visio in our case) should work!