C# applicationHost.config not found but exists

456 views Asked by At

I'm getting a strange error when accessing applicationsHost.config. I've run VisualStudio in administrator mode and trying to access

C:\Windows\System32\inetsrv\config\applicationHost.config

but I get exception FileNotFound while file exists.

var file = @"C:\Windows\System32\inetsrv\config\applicationHost.config";
var fileExist = System.IO.File.Exists(file); //it always returns false
var fi=System.IO.File.OpenRead(file);  //Throws FileNotFound exception

I've tested on VS2013 and VS2017 on Windows 10. I don't get any error related to permission and even I've added Everyone to the folder to be sure it's related to that.

2

There are 2 answers

0
pers On

It turned out it's related 'File System Redirection' on Windows 8.1 onward. So %windir%\System32 would be redirected to %windir%\SysWOW64 Thanks to @NGambit I had to change config type to x64 to be able to access applicationhost.config

0
ivan ivanov On

if using net framework app, change target platform to x64 in project properties