0

i have console application in which it will try to access an application installed in IIS (i.e. virtual directory) for getting the db connection information. While doing this in windows xp (IIS 5.1), it is working, but it is not working in windows 7 (IIS 7.5). The console application's Target .Net framework is 2.0, 3.5 (having 5 applications), since, it was developed years ago. Now trying to move from XP to Win 7, but facing some issues with accessing the IIS folder. Please advise to access the virtual directory folder in win 7. Any code example will help a lot.

*Error:*System.Runtime.InteropServices.COMException (0x80070005): Access is denied.

1 Answers1

1

It would be useful to have a look at the piece of code which you are using to access the virtual dir, but before changing the code, check if the problem is due to security permissions. If you are trying to access the physical directory associated with the virtual dir in Windows 7, you might be running your console app without enough privileges. Please try running it with administrative privileges.

After cheking your code, I see that you are using Directory Services to access IIS 7 so please make sure that in that machine you have installed IIS Metabase and IIS 6 configuration compatibility. In Windows 7 you can find it in Control Panel -> Programs -> Programs and Features -> Turn windows features on off, and then go to Internet Information Services –> Web Management Tools –> IIS 6 Management compatibility. You need to enable the check in IIS Metabase and IIS 6 configuration compatibility

Nevertheless, the suggested way to access and administer IIS 7 from code is by using the IIS Management API available through the Microsoft.Web.Administration library. You can take a look at an example showing how to perform this same task you need in the following question:

How to get the IIS virtual dir & web application's physical paths with C# code?

Community
  • 1
  • 1
Jose Antonio
  • 451
  • 2
  • 7
  • 24
  • I have posted my code which is used to access the virtual directory. Works in XP (IIS 5.1) but not win 7 machine (IIS 7.5). Sorry the code became clumsy after posting it here. – Venkatramanan Lakshmanan Oct 03 '13 at 06:50
  • I have also tried running with administrative privilege, but, still getting the same error while trying to the connection parameters from IIS virtual dir. Please advise – Venkatramanan Lakshmanan Oct 03 '13 at 07:58
  • Please take a look at the edited answer after checking your code. HTH – Jose Antonio Oct 04 '13 at 06:57
  • Thanks for the reply @Jose Antonio. I will try your suggestion and will post the status again here. – Venkatramanan Lakshmanan Oct 04 '13 at 07:10
  • IIS Metabase and IIS 6 configuration compatibility checkbox is already checked in my win 7 machine. I tried again, but, still getting the same error.. – Venkatramanan Lakshmanan Oct 04 '13 at 07:37
  • Your code works on my machine when turning off UAC, and throws the same error when turning it on again, so I guess your problem deals only with permissions. I suggest you writing a small program using the IIS Management API that I have pointed you right now in the answer and check if it runs ok by launching through command line with administrative privileges. – Jose Antonio Oct 04 '13 at 11:34
  • I also gave permission to one of the system folder named Config (Location --> C:/Windows/System32/Inetsrv/). I permit my application's app pool to have access to this folder and also as you have suggested, i have enabled the IIS Metabase and IIS 6 configuration compatibility and it worked. Thanq very much @Jose Antonio – Venkatramanan Lakshmanan Oct 15 '13 at 08:37