ChatGPT解决这个技术问题 Extra ChatGPT

Error - Unable to access the IIS metabase

After installing Visual Studio 2012 and opening my solution I get a series of errors in this form:

The Web Application Project Foo is configured to use IIS. Unable to access the IIS Metabase. You do not have sufficient privilege to access IIS web sites on your machine.

I get this for each of our web applications.

Things I have tried:

Running Visual Studio as Administrator Running aspnet_regiis.exe -ga MyUserName Running aspnet_regiis.exe -i

These seem to be common solutions for this problem but I have not had any success with them.

Is there anything else I can try to do?

Are you definitely running as admin? Do you get a User Account Control dialog popup when you launch VS?
i had the same issue and when i ran VS as administator ( right click and select run as administrator) , it worked
For anyone that comes here later I solved this problem by turning off the IIS and .Net Framework features within Windows 7 and then turning them back on. Somewhere in that re installation it fixed my problem.
Before you follow any advice posted here, please check if you have pending Windows updates. I had plenty which needed a reboot, finishing the updates fixed the problem.
I had the same problem after Adding feature from this link and then I read this article the issue was gone.

A
Atron Seige

On Windows 8 Pro:

%systemroot%\inetsrv\config

On Windows 7 and 8.1 and 10

%systemroot%\System32\inetsrv\config 

(Where %systemroot% is usually C:\Windows)

Navigate to the appropriate location above in Windows Explorer. You will be blocked access with a popup which says:

"You don't have access to this folder - Click continue to permanently get access to this folder"

Click 'continue' for this folder, and with the Export folder underneath. I changed the shortcut back to "Run as me" (a member of the domain and local administrators ) and was able to open and deploy the solution.


It worked, thanks. Just one note, config folder can be located in C:\Windows\System32\inetsrv\config
%systemroot%\System32\inetsrv\config (i.e. C:\WINDOWS\System32\inetsrv\config) on windows 8.1 works nice
%systemroot%\System32\inetsrv\config was the correct path for Windows 7
@Nate, the problem is that when VS loads the project, it tries to access the IIS metabase, which is in that directory. IIS, on your computer, is locked down under admin privileges. So when you open VS as a normal user, you can't access IIS's metabase and VS can't load the project. (On Windows 7+, you access everything as a normal user by default. The problem is that VS won't ask you to elevate your privileges when you need to, so you need to manually grant the permissions to access that directory to yourself.)
%systemroot%\System32\inetsrv\config for Windows 10, too.
F
Felipe Ardila

I think you are not running visual studio with administrator permissions. Look that:

http://bloggingabout.net/blogs/rick/archive/2012/10/04/unable-to-access-the-iis-metabase.aspx

To quote

The solution to this is simple: start your Visual Studio with "Run as Administrator". You can do this by right clicking the shortcut and selecting "Run as Administrator".


I am definitely running as administrator. I do receive the UAC prompt and it launches successfully from there. I used this with VS2010 as well.
If you want to avoid the pain of running your visual studio as administrator every time (which IMHO is a better solution) then check the response by GordonK2004.
-1 from me.This blog promotes running the IDE as Administrator all the time. This will get you into 101 problems writing correct code that works correctly inside security restricted environments that your users will want/need to deploy into. It is much better to solve each security matter as it crops up in development (as your test each part of the code well) and document the solution needed for users/installer than to turn this Run-as-Administator off just before you roll a release and hope your testers find every security concern you wallpapered over (the cracks).
@DarrylMiles Care to share a real-world example where doing this caused a security issue?
This is an awful answer, real shame that it's been upvoted so far. Running your VS as an admin is a work-around, not a solution.
J
Jeff B

https://i.stack.imgur.com/pa800.png

Give that a try and let me know if it helps!

Note: We're running IIS 7.5 on Windows 7 using both Visual Studio 2005 and 2010 and doing stuff with super-old-school WebServices (.asmx)...


I tried all the other solutions (config folder permissions, not use IIS, run VS as admin, restart IIS, etc.), but this was the only solution that worked for me. Thanks for sharing!
Thanks, this helped me too. I am using VS2013 and the project file's config files structure is different than Bruno Sena's answer. I was about to pull my hair out, but then I remembered I'm bold and opted to try this solution which was a quick fix.
Ensure IIS Admin service is started and set Startup type to Automatic instead of Disabled.
Based how restricted your configuration is this might also need admin priviliges.
n
nhahtdh

I resolved this issue by granting IIS AppPool identity permissions to the %systemroot%\inetsrv\config


Perfect! Don't need to bother anymore running as Admin. Folder for Win 7 is located here: C:\Windows\System32\inetsrv\config
This worked for me too, Windows 8.1, IIS 7.0, VS 2012. Thanks so much
should be %systemroot%\system32\inetsrv\config
k
kira_codes

If you are working on a project which does not require the use of IIS, then a workaround to open the project with this error is to simply right click on the unloaded project and click edit, search for:

<ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="">
        <WebProjectProperties>
          <UseIIS>True</UseIIS>
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
</Project>

and set USEIIS to false

<UseIIS>False</UseIIS>

reload the project by right clicking on it after saving changes.


This works for me, but what is the underlying problem here? It must be false on my desktop but true on my laptop. So if I check a project into the TFS on my laptop, it fails to load on my desktop, and vice versa until I change this.
How does this help solve the problem of not being able to use IIS?
Setting <UseIIS>False</UseIIS> did not work. The node <UseIISExpress>true</UseIISExpress> was present as well. Setting it to false did not help. Still the same error access to iis metabase is needed.
This "works" for me and there seems to be confusion on this. Most projects can run under iis express on a person's local machine. Some projects required full IIS. All I needed to do was load the project in VS so I could look at it. If I tried to run it under express it would likely have some kind of run time error. The other developers that actually develop this project and test locally take the time to install IIS locally. So this does not solve the runtime issue. However, someone needs to load it in VS so they can work on it to solve the run time issue so this is a valid answer.
C
Community

I have had two seperate types of problem lead to this error, and thought I'd share...

1. The directory was on an network share and due to UAC restrictions, was 
   unable to be accessed -- even when running as an admin.
2. The directory was on a drive that didn't exist...

Both of these stem from an unfortunate (imo) choice by MS to put things in the Documents or My Document directory, combinee with really lousy error messages. In both of the above cases the fundamental problem was that the IISExpress Config file goes in My Documents, and it either didn't exist or couldn't be accessed.


How did you solve the problem. I think I'm facing with one the 2 problems.
Make sure that both the Projects directory and My Documents directory are on a local disk drive. I put them both on C:\.
Our VPN dies often and leaves HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal pointing to non-existant fileshare. Changing that to local path solved this problem for me.
The solution for me was to copy the IISExpress folder from my Documents folder on another machine to my new machine, and then things started working.
j
jjathman

Thank you to everyone that answered. Since this was closed for a long time I couldn't provide much feedback, but I did eventually fix my problem. I tried many of these other solutions and they didn't fix my issue, but I'm sure they help when the root cause is different.

My Solution

I solved this problem by turning off the IIS and .Net Framework features within Windows 7 and then turning them back on. It seems like this re-installation is what fixed my issue. I still don't know what caused the problem, but at least one other developer on my team had the same issue.


N
Neuron

Navigating to folder: %systemroot%\System32\inetsrv\config presents a security dialog. Click continue and this may resolve the issue. This has worked on two separate Win 10/VS 2017/IIS machines.


This has worked for me before as well. Today, trying it on a new laptop, I did not get the security dialog when navigating to the folder, I simply could not get into the config directory at all. I had to right-click and change the permissions on the folder (which required using my local admin access) and give myself permissions, then it worked.
C
Community

On a windows 81, from an admin command prompt, use:

icacls "C:\Windows\System32\inetsrv\config" /t /grant "IIS AppPool\DefaultAppPool":(R)

Then go back in VS, right click on the failed project, choose Reload.

Credit to: IIS7 Permissions Overview - ApplicationPoolIdentity


No. This will give read-permissions to the IIS configuration to the web application pool which runs as that identity. Visual Studio doesn't run with this identity, so it doesn't help for this question. Further, why would you let the application pool access the IIS configuration? That's asking for trouble.
+1 but rather than granting access to the DefaultAppPool, I gave read/write access to my user and that fixed the error.
I did the same as David, except with full control (F) and it resolved my issue.
s
sargeMonkey

I had this problem - the symptoms were the same, but the issue I had was that I had set the "My Documents" folder to be on a network share, and the share was not accessible.

The root problem was that the IIS config files located at %USERPROFILE%\Documents are not accessible. Once I changed the "My Documents" folder location (I modified the reg value), it started working again.

I know that this may not be a common scenario that you might run into, but I've posted it here because it gives the same symptoms.


We work in a VM, co-worker ended up setting a shared folder which ended up using the "My Documents" folder to a network path. As this answer stated, it does not work without the documents folder. I will check if this folder is available first thing in the future to save the 2hrs we spent going through these posts and such lol.
I had this problem also. My Documents folder was on a network share and a network issue was preventing access. Once I resolved the network problem Visual Studio stopped giving the IIS Metabase error.
R
Rushby

I came across this today and fixed the problem by removing the IISUrl from the Project file:

Right click project Click Edit Delete the following line: http://localhost:xxxxx Reload project Now add a new IIS virtual directory by right clicking Project > Properties > Web and selecting Use Local IIS Web Server (Uncheck Use IIS Express) and clicking the Create Virtual Directory button.


This will not solve the OP issue because you cannot open the project to change the URL when you get this error.
I partially disagree with @htm11h. I had the OP's error and removed the single entry above (outside of VS). I then ran VS and was able to at least open the properties. It wouldn't let me save the edits though, so I had to open %systemroot%\System32\inetsrv\config once and continue as admin; also open %systemroot%\System32\inetsrv\config\Export and do same. (error-unable-to-access-the-iis-metabase)
My comment was that it was not repairable from within VS as you noted. Nice to know that you can directly edit the file though, its was not identified at the time. Most were searching for a reg hack.
T
Tom Stickel

You might run across this problem and have same problem as me. I "solved" it before and then power outage and computer crashed, not sure why a registry setting reverted but it is the SOURCE of my problem.

I tried all the running as adminstrator All the IIS / IIS express re-installs. Various "hacks"

Came down to having to fix the registry again.

Could not as administrator even open regedit (Need to access registry since problem is not with gpedit.msc admin template ) UnHookExec.inf on desktop

Just save UnHookExec.inf and install it by right clicking and selecting install. Installing the file will not show any popup or notice box. http://www.tweakandtrick.com/2011/04/enable-regedit-registry-editor.html

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal pointing to non-existant fileshare. Changing that to local path solved this problem for me. – Pasi Savolainen Jul 14 '14 at 8:41

(changed from \\cs2data\home\stickelt\my documents to c:\dev )

Now ALL is good and Visual Studio opened solution with 15 projects and connects to IIS and does not complain about not being able to access iis metadata

I had never ran into this before, as nobody at current job had this problem ( many have been here a long time, some got clones of other machines that "worked" and many are on another domain etc.. )


S
Saurabh Soni

I just had this issue today and I found that I didn't open VS as 'Run as Administrator'. After doing this, I was able to publish the Service.


R
Ramazan Sağır

If you have administrator permissions, Right Click to Visual Studio icon > properties and then advanced, "Run as administrator" check. You can run visaul studio as administrator directly anymore. This way, formal and so basic.


C
Community

In addition to the answer by @nologo, I also had to use IIS. So I changed the

<UseIIS>True</UseIIS>

to 'False' first.

Opened the solution and ensured that the project could be loaded.

Close solution and that instance of Visual Studio

Change the value to 'True' again

Open the solution. This time, I didn't get any error/warning. I could also run with Ctrl+F5 or F5 without any problem while my project was mapped to an IIS website.


This helped me with VS 2015, Win10. Useful hints in here, nasty problem. Thanks a lot.
This is in the web.config? If so, where?
@BobHorn This is in the csproj or vbproj file. Open the file in a text editor.
g
garryp

Changing this key worked for me:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal

The location didn't exist.


I had to change the key you mentioned, and also HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal. This was due to the profile path being set to a non-existent directory in Active Directory/Group Policy.
A third culprit is HKEY_CURRENT_USER\Software\Microsoft\IISExpress, which is an override custom dir, and another potential culprit for this problem
E
E2rdo

Go to the root directory of your project and find the following file: YourProjectName.csproj.user - inside it, make sure UseIISExpress is set to false:

<UseIISExpress>false</UseIISExpress>

If that alone doesn't work try the following as well and try again:

YourProjectName.csproj - inside the main project file, make sure both UseIIS and UseIISExpress are set to false:

<UseIIS>True</UseIIS>
<UseIISExpress>false</UseIISExpress>

After changing these I was able to load the project again.

Note: Make sure you run your VS as an Administrator, as mentioned in the other answers.


F
Francis Rodgers

I also had a similar problem. My solution is an extension to the answer "Run as admin" which I hope someone might find useful.

I was running VS2012 and almost every time I had to do the Right Click, Run As Administrator. I got tired of this so instead I went into its properties on the shortcut, clicked advanced, and then clicked the "Run as Administrator" option. Now VS2012 always runs as administrator whenever I open it from that shortcut.

The from that shortcut bit is important. I proceeded to branch my project, and download the branch to a new local folder. Then, when I opened it from the shortcut I had no problem. But if I went directly into the folder, and ran the project locally without the shortcut, it did not run as administrator and I got this error.

Once I opened VS2012 as usual first, then using File/Open/Project It worked again no problem. (because I was running as admin). But I wasn't running as admin when I opened the solution using windows file manager.

The other suggestions seem somewhat extreme, but this is pretty simple so I would tend to give this a try first.

Hope this was helpful.


N
Nathan Tregillus

This seems like one of those "All errors lead to this message" type of bugs.

Mine was that the App Pool was just turned off. I turned it back on, and everything worked fine.


T
Thomas Eyde

One more thing you could try:

Check if you have pending Windows updates.

If you do, please reboot before trying anything else.

I tend to never shut down my machine, so I had plenty of them waiting for a reboot. And that fixed it.


s
scottt732

I tried everything above. The credit goes to all of the responses above. Having tried all of the suggestions on their own, I just assembled this combination of suggestions in an order that made sense to me. Note my Documents folder is on a shared drive. The subst/IISExpress stuff is not applicable unless you're in the same boat.

Configure VS to run as admin

Uninstall IIS via Add/Remove Programs, Windows Features

Reboot

Run WinRAR or something similar as admin and archive C:\windows\system32\inetsrv\

Run cmd as admin and rmdir /s c:\windows\system32\inetsrv\ to completely remove all traces of the last install. Leave elevated cmd prompt open for later.

Reinstall IIS with IIS 6 Metabase compatibility (doubt this was necessary)

Leave Default AppPool and Default Website as-is (I had previously deleted both)

Ran C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ga MYDOMAIN\scottt732

Ran C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i

Also, because my Documents folder is on a share drive, I was having IIS Express issues. I don't use/like IIS Express, but Visual Studio complained about it.

From elevated cmd prompt, ran subst U: c:\Temp. Created C:\Temp\Documents\ and copied the IISExpress folder from my U drive.

Created CustomUserHome key in HKCU\Software\Microsoft\IISExpress with C:\Temp\Documents\IISExpress

This allowed me to get Visual Studio to open my web projects and edit the properties. I tweaked the projects to store web server settings in a user file and adjusted it to use a Custom URL (not sure if this was necessary)

I may/may not have to run the subst command each time I restart. Don't care.

And after throwing in the towel 3 times and spending roughly ~6 hours I can open web projects in Visual Studio (2015 Update 2).


Note to future me: I updated Windows 10 to a preview release & it broke again. This time I ran the 2x aspnet_regiis and the subst command and am back in business. Oh. And don't forget to wind your watch.
K
KMX

I just had the same issue with me today. And I found it annoying. Though I have other two websites already under development from the same IIS but still was not able to create new site. Strange, but I did this.

Delete the site from IIS

Create new site, give it a name "new_site"

Select Application Pool other than the site name itself. So it wont be messing up with default settings.

Keep IP "unassigned" if you are running it from same machine

give it some unused port

Run Visual Studio as "Run as Administrator" by right-clicking on VS executable shortcut.

You are done!

You do not need to turn off/re-install anything other than what I have stated since it works.

Let me know if anybody had the same issue just like me and solved the same way. I think it was not the issue but a wrong way of creating website on localhost which Visual Studio rejects to open.

I hope this will help newbies.


M
Mauricio Gracia Gutierrez

Create a shortcut to the "devenv.exe" select the "Run as administrator" option for the shortcut doble click on the short cut and reopen your project


C
Community

I had the same problem after Adding feature from this link afterward I followed this article the issue was gone.


K
Kenmeister

I did a repair of Visual Studio 2015 to solve this. The repair took a long time, but it solved the issue while doing much of the above did not. I am running Win 7 enterprise.


佚名

Open visual studio command prompt and type below command and run

aspnet_regiis -ga machinename\ASPNET

After running the above command Reset the IIS and test the application that resolve your issue.

If above command doesn’t resolve your problem then try to run below command in visual studio command prompt:-

aspnet_regiis -i

Alternatively we can run above command from our windows command prompt also

Go to the Start menu and open Run and enter and click OK

%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe –I

After that Reset the IIS and test the application that resolves your issue


A
Arvind Krmar

In Visual Studio 2015: I changed UseIIS in .csproj file to false and it worked for me.

<UseIIS>False</UseIIS>

u
user2686690

In my message, beside complaining about "Unable to access the IIS metabase", it also mentions can't access "<IISUrl>http://localhost:6416/</IISUrl>". Right click on the unload project, click Edit, find the line "<IISUrl>http://localhost:6416/</IISUrl>", comment it out. Reload and it should work. This has to do with administrator doesn't have permission to access that address.


J
JGa

I had a similar problem. Visual Studio would not load any web projects and showed the error: creation of virtual directory failed. Unable to access the IIS metabase.

In my case it was actually IISExpress that was at the root of the problem. Right clicking on IIS Express in Programs and Features in the control panel and choosing repair fixed the issue in less than two minutes.


Y
Yossi

I'm using Win 8 Pro and VS 2013. After trying everything in this page... I simply reinstalled IIS Express 8 and everything works fine now (even without running as an admin).

My conclusion is that this is a rather generic error and there are multiple root causes.