Can’t write to applicationhost.config

While running Visual Studio 2015 as well as 2017 I’ve come across the following error running Web projects with IISExpress:

2017-04-03 21_30_15-applicationhost.config

—————————
Microsoft Visual Studio
—————————
The following error occurred when trying to configure IIS Express for project MvcClient. Filename: \\?\C:\Project\.vs\config\applicationhost.config
Error: Cannot write configuration file
—————————
OK
—————————

I did some digging found with Sysinternals Process Monitor and found a bunch of SHARING VIOLATION file access errors on the file. Searching a bit deeper for the first record for that file, I found a record with the result EFS NOT ALLOWED IN TRANSACTION. Okay, now I was on to something:

2017-04-03 21_33_25-Process Monitor - Sysinternals_ www.sysinternals.com.png

EFS Stands for Encrypting File System. This is a Windows feature that allows you to encrypt specific files or folders. You enable this via the Windows Explorer properties box under the Advanced button.

I remembered that a while ago that I enabled EFS on some of my data because I can’t use BitLocker drive encryption on this machine. Unfortunately BitLocker isn’t a practical option because I’m running Windows 10 on a MacBook pro via Bootcamp.

Turns out the fix was as simple as disabling EFS for the relevant .vs folders!

2017-04-03 21_44_39-Advanced Attributes

Unfortunately I still don’t know why EFS wasn’t “allowed” as per the original message. It looks like Visual Studio did manage to create the file, so I don’t know the reason it complains at run-time. For know I don’t really care though, as it’s easy enough to disable EFS. I’ll continue using EFS overall, just disabling it on the .vs folders which don’t contain anything I don’t mind losing.

2 thoughts on “Can’t write to applicationhost.config

  1. KP June 16, 2018 / 01:27

    Thank you so very much! I was getting super frustrated and was struggling with this for weeks! I did everything.. regedit, config edit etc but nothing worked. This did! and it was such a simple fix! Thank you!

  2. MM November 14, 2018 / 03:15

    this really helped me. thanks.

Leave a comment