27

I am running C# ASP.NET 4.5 web application on Windows 7 64-bit using IIS 7.5. The application pool it uses has the name 'ASP.NET v4.0' and its identity is ApplicationPoolIdentity. The application uses MS Office Interop (Microsoft Excel 14.0 Object Library).

At line wBook = wBooks.Add(Missing.Value);, it throws the following error:

Microsoft Excel cannot open or save any more documents because there is not enough available memory or disk space.

u2022 To make more memory available, close workbooks or programs you no longer need.

u2022 To free disk space, delete files you no longer need from the disk you are saving to.: at Microsoft.Office.Interop.Excel.Workbooks.Add(Object Template)

1) I gave the account IIS apppool\ASP.NET v4.0 full control on MS Excel Application in DCOM Config.

2) I gave IIS apppool\ASP.NET v4.0 full control on 'C:\Windows\SysWOW64\config\systemprofile' and created a Desktop folder in it.

3) I need to continue using Interop though it's not recommended.

4) The application works fine on Windows Server 2003/Windows XP 32-bit.

5) MS Office 2010 (64-bit, trial version) is installed on the machine.

6) I would prefer not to change the app. pool identity from ApplicationPoolIdentity to Network Service etc.. ApplicationPoolIdentity is the new type of Identity in IIS 7 and it's recommended.

It works fine if I select 'Interactive User' (I have logged in as an admin) in DCOM Config, but it causes other problems. I need to use 'Launching User' which is ASP.NET v4.0. So it looks like it's a permission issue.

Please help. Thank you.

Nima Derakhshanjan
  • 1,380
  • 9
  • 24
  • 37
engg
  • 343
  • 1
  • 4
  • 12
  • 1
    There's ample disk space and memory, so it's not the issue. So I haven't been able to fix it yet. – engg Sep 13 '12 at 22:35
  • 3
    You will almost certainly need to change the identity the application pool is running under to a user that has previously logged in interactively and run Excel in order to be able to use Excel from the web app. Alternatively, you could change the DCOM config to a specific user rather than launching or interactive and give it the login details for your admin user to test out if that makes any difference. – Nanhydrin Sep 14 '12 at 09:56
  • Thanks Nanhydrin, that will probably work. Why does ApplicationPoolIdentity not work? – engg Sep 14 '12 at 20:09
  • May be you are using more than one instance of Excel everytime to generate the document? – Ruchi Nov 16 '12 at 22:36
  • No, there's just one instance. – engg Nov 30 '12 at 19:11
  • 1
    @Ken you should not trust every error messagae as the bible. See my answer. The problem had NOTHING to do with memory or disk space. – Tony_Henrich Jul 05 '13 at 18:41

7 Answers7

43

Right click on the file with file explorer, choose Properties, then General tab and click on the Unblock button. This error message is very misleading.

Pavel K
  • 3,541
  • 2
  • 29
  • 44
Tony_Henrich
  • 42,411
  • 75
  • 239
  • 374
  • Also if you cannot see this button, it means that the file is not blocked and you should search for another solution. – Pavel K Nov 15 '13 at 07:03
  • what about after deploy my application. this could not be a good solution which seems machine specific . I hosted my application on windows azure , and getting this error what to do ? – Neo May 18 '14 at 11:55
  • 5
    @PavelK What file am I supposed to right click on? Please, could you be more specific? – silkfire Oct 09 '14 at 09:58
20

Go to this key on Registry Editor (Run | Regedit) HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

change key Cache to something like C:\Windows\Temp

My similar problem was solved like this.

Regards,

Ripley

Ripley
  • 209
  • 2
  • 3
  • Was so mad until I saw this, life saver! – Dr Archer Mar 15 '17 at 23:40
  • Worked for me after HOURS of trying other things. Thanks! (p.s. I changed both HKCU and HKLM so I am not sure which worked... since no one will be logged on when it runs for real...there will be no CU). – AWhatley Nov 14 '19 at 22:47
  • 1
    ABSOLUTE HERO! I couldn't open any of my Excel documents. Tried everything suggested online. This worked, finally. – Luigi Plinge May 03 '20 at 21:08
  • Wow, literally all day researching this and trying everything else suggested, this worked. Who knew automating the creating and sending of a spreadsheet would be so difficult? – KAThompson Aug 13 '21 at 18:32
7

I had this same issue, there was no issue regarding memory in my server machine, Finally i was able to fix it by following steps

  1. In your application hosting server, go to its "Component Services"
  2. enter image description here

3.Find "Microsoft Excel Application" in right side.

4.Open its properties by right click

5.Under Identity tab select the option interactive user and click Ok button.

Check once again. Hope it helps

NOTE: But now you may end up with another COM error "Retrieving the COM class factory for component...". In that case Just set the Identity to this User and enter the username and password of a user who has sufficient rights. In my case I entered a user of power user group.

Nithin Paul
  • 2,169
  • 3
  • 33
  • 55
5

Test like this.Sometimes, permission problem.

cmd => dcomcnfg

Click

Component services >Computes >My Computer>Dcom config> and select micro soft Excel Application

Right Click on microsoft Excel Application

Properties>Give Asp.net Permissions

Select Identity table >Select interactive user >select ok

Nima Derakhshanjan
  • 1,380
  • 9
  • 24
  • 37
Boopathi.Indotnet
  • 1,280
  • 15
  • 18
2

I too encountered the same scenario and found out two solutions after googling for several times. Hope this helps.

Way 01:

Before trying to open the file in Excel, find it in Windows' File Explorer. Right-click the file and select Properties. At the bottom of the General tab, click the Unblock button. Once you unblock a file, Windows should remember and Excel should not ask you again. This option is available for some file types, but not others. If you don't have an Unblock button, use Way 2.

Way 02:

This option is better if you usually store your downloaded Excel files in one folder. In Excel, click File » Options » Trust Center » Trust Center Settings » Trusted Locations. Click Add new location. Browse to the folder where you store your Excel files, select Subfolders of this location are also trusted, and click OK.

Du-Lacoste
  • 11,530
  • 2
  • 71
  • 51
  • You should at least provide a link when you copy-paste from a [source](http://kb.palisade.com/index.php?pg=kb.page&id=1542). – LoMaPh Apr 18 '19 at 15:46
0

If none of the above worked, try these as well:

  • In Component services >Computes >My Computer>Dcom config>Microsoft Excel Application>Properties, go to security tab, click on customize on all three sections and add the user that want to run the application, and give full permissions to the user.

  • Go to C:\Windows\Temp make sure it exists and it doesn't prompt you for entering.

LoMaPh
  • 1,476
  • 2
  • 20
  • 33
0

After giving necessary permissions in DCOM configurations I also needed to change the identity of my application in the IIS to a custom account

Dharman
  • 30,962
  • 25
  • 85
  • 135
MohammadHossein R
  • 1,249
  • 1
  • 16
  • 30