简体   繁体   English

创建虚拟目录失败并显示错误

[英]Creating a virtual directory failed with the error

I can't solve this problem我无法解决这个问题

在此处输入图片说明

I suggest I have to change c:\\Windows\\System32\\drivers\\etc\\hosts file and add after我建议我必须更改c:\\Windows\\System32\\drivers\\etc\\hosts文件并在之后添加

# localhost name resolution is handled within DNS itself.

the next line:下一行:

127.0.0.1       mysite.dev

but it doesn't help.但它没有帮助。 Any suggestions?有什么建议?

Error ocсurrs when I try to open web site project in Microsoft Visual Studio 2012.当我尝试在 Microsoft Visual Studio 2012 中打开网站项目时出现错误。

More often than not, at least in my case, this happens is when a *.csproj.user file is in the project directory and has <UseIISExpress>true</UseIISExpress> in it.通常情况下,至少在我的情况下,当*.csproj.user文件位于项目目录中并且其中包含<UseIISExpress>true</UseIISExpress>时,会发生这种情况。

Alternatively, as mentioned by Zachary Cutler you can also simply: close Visual Studio, delete the *.csproj.user file and reopen Visual Studio .或者,如Zachary Cutler所述,您也可以简单地:关闭 Visual Studio,删除*.csproj.user文件并重新打开 Visual Studio This will force VS to rebuild the file.这将强制 VS 重建文件。

I've already found the solution.我已经找到了解决方案。 I just had to edit C:\\Users\\Administrator\\Documents\\IISExpress\\config\\applicationhost.config file, by adding my site to <sites> node.我只需要通过将我的站点添加到<sites>节点来编辑C:\\Users\\Administrator\\Documents\\IISExpress\\config\\applicationhost.config文件。

You can opt to install IIS locally and edit a couple of tags on .csproj File.您可以选择在本地安装 IIS 并在 .csproj 文件上编辑几个标签。 Open you csproj file and go to section <VisualStudio> then find tag <UseIIS>True</UseIIS> it must be set as true, then go to tag: <IISUrl> and set up with the URL address where the application will be hosted for testing:打开您的 csproj 文件并转到<VisualStudio>部分,然后找到标记<UseIIS>True</UseIIS>它必须设置为 true,然后转到标记: <IISUrl>并设置将托管应用程序的 URL 地址用于检测:

<VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
          <UseIIS>True</UseIIS>
          <AutoAssignPort>False</AutoAssignPort>
          <DevelopmentServerPort></DevelopmentServerPort>
          <DevelopmentServerVPath>/</DevelopmentServerVPath>
          **<IISUrl>http://localhost/myWebSiteAppSample</IISUrl>**
          <NTLMAuthentication>False</NTLMAuthentication>
          <UseCustomServer>False</UseCustomServer>
          <CustomServerUrl>
          </CustomServerUrl>
          <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>

And that is.那就是。 Now you can load your project normally.现在您可以正常加载您的项目了。

The problem would be your project setup to be executed in the local IIS and the URL specified not exist.问题是您的项目设置要在本地 IIS 中执行并且指定的 URL 不存在。

There are options you can do to fix the problem.您可以通过多种选择来解决问题。

Option 1 : (Use IIS Express)选项 1 :(使用 IIS Express)

1.) Open you web project .csproj file as XAML or in notepad. 1.) 以 XAML 格式或在记事本中打开您的 Web 项目 .csproj 文件。

2.) Find these properties and set according to your preferences. 2.) 找到这些属性并根据您的喜好进行设置。

UseIIS = false使用IIS = false

UseIISExpress = true使用IISExpress = true

and that's it.就是这样。

Option 2 : (Use local IIS)选项 2 :(使用本地 IIS)

Follow the option 1 steps but change the following properties.按照选项 1 的步骤操作,但更改以下属性。

UseIIS = true使用IIS = true

IISUrl = https://localhost IISUrl = https://localhost

UseIISExpress = false使用IISExpress = false

The issue can be fixed by deleting the folder named .vs in the project directory.该问题可以通过删除项目目录中名为 .vs 的文件夹来解决。

This solves the problem because while opening the project after deleting the .vs file, it creates the same folder with subfolder config and folder with project name.这解决了这个问题,因为在删除 .vs 文件后打开项目时,它会创建相同的文件夹,其中包含子文件夹 config 和具有项目名称的文件夹。

The config folder applicationhost contains the necessary settings required to run the project successfully. config 文件夹applicationhost包含成功运行项目所需的必要设置。

我只是转到错误中命名的目录并重命名 applicationhost.config 并重新启动,VS 创建了一个新文件并运行良好。

  • Tried several approaches mentioned in the answers, but what finally worked for me was swapping the <IISUrl> of .csproj with <CustomServerUrl> .尝试了答案中提到的几种方法,但最终对我<IISUrl>是将.csproj<IISUrl><CustomServerUrl>交换。

Edit :编辑 :

  • The above didn't solve the root cause of the issue for me.以上并没有为我解决问题的根本原因。 However, If you've done a windows update recently, perhaps it might be the reason that's causing the issue.但是,如果您最近进行了 Windows 更新,这可能是导致问题的原因。 Try executing netsh http add iplisten 0.0.0.0 and see whether it solves the issue.尝试执行netsh http add iplisten 0.0.0.0看看是否能解决问题。

Hope these would help someone still looking for a way.希望这些能帮助仍在寻找方法的人。

I don't know why, by my applicationhost.config file was completely missing from my C:\\Users\\Administrator\\Documents\\IISExpress\\config\\ folder.我不知道为什么,我的applicationhost.config文件从我的C:\\Users\\Administrator\\Documents\\IISExpress\\config\\文件夹中完全丢失了。

Copy/pasting C:\\inetpub\\history\\applicationhost.config into that folder seemed to fix the problem for me.C:\\inetpub\\history\\applicationhost.config复制/粘贴到该文件夹​​中似乎解决了我的问题。

Got the idea from here .从这里得到了这个想法。

  1. Turn on windows features "Internet Information Services" in control panel.在控制面板中打开 Windows 功能“Internet 信息服务”。
  2. Open ".csproj" file and find打开“.csproj”文件并找到
  3. Modify this line based on your requirements.根据您的要求修改此行。 http://localhost:777/ http://本地主机:777/
  4. Open the project/solution now立即打开项目/解决方案
  5. If failed to load again, just right click the solution and select "Reload Project".如果再次加载失败,只需右键单击解决方案并选择“重新加载项目”。

I know this is probably a rare occurrence, but figured I'd put it here:我知道这可能很少见,但我想我会把它放在这里:

My csproj file was set to "read only" (Don't ask me how I managed that), but after I turned off "read only" access, everything was fine.我的csproj文件被设置为“只读”(不要问我是如何管理的),但是在我关闭“只读”访问后,一切都很好。 (VS2017) (VS2017)

Not the exact same error, but I was lead to this answer since the first half of the error matched.不是完全相同的错误,但是自从错误的前半部分匹配以来,我就得到了这个答案。 Your applicationhost.config file may simply be read-only.您的 applicationhost.config 文件可能只是只读的。 Taking that off solved the error for me.取下它为我解决了错误。 That error calls out the file specifically though, so you should be able to find it easily.不过,该错误会专门调用该文件,因此您应该能够轻松找到它。

I had to somewhat combine some of the above answers.我不得不将上面的一些答案结合起来。 My solution was to edit (not delete) the file .vs\\config\\applicationhost.config我的解决方案是编辑(而不是删除)文件.vs\\config\\applicationhost.config

There is a section for the bindings of the site, simply change from localhost to whatever you desire to run it under.有一个用于站点绑定的部分,只需将 localhost 更改为您希望在其下运行的任何内容即可。 Note that the port numbers are in front of the server name.请注意,端口号位于服务器名称之前。

applicationhost.config 绑定部分

I was able to resolve this by editing the file *.csproj in the root level of the project.我能够通过编辑项目根级别中的文件 *.csproj 来解决此问题。 I changed and from localhost to the site name as shown below.我将 localhost 更改为站点名称,如下所示。 It may also be required to have the OverrideIISAppRootUrl set to True.可能还需要将 OverrideIISAppRootUrl 设置为 True。 在此处输入图片说明

I was facing the same issue because of my network password changed.I changed my NetExtendor login password but I have to login in my laptop with old password.由于更改了网络密码,我遇到了同样的问题。我更改了 NetExtendor 登录密码,但我必须使用旧密码登录我的笔记本电脑。

Try these steps to fix this issue:请尝试以下步骤来解决此问题:

log into the Computer with whatever password works log into vpn with whatever password works ctl-alt-del to lock the pc then use the new password to unlock it使用任何有效的密码登录计算机 使用任何有效的密码登录 vpn ctl-alt-del 锁定电脑然后使用新密码解锁它

It worked for me :-)它对我有用:-)

Thanks!谢谢!

So here are the steps to fix it:所以这里是修复它的步骤:

  1. Go where your .csproj file is.转到 .csproj 文件所在的位置。 This is usually one directory below the solution (.sln)这通常是解决方案 (.sln) 下面的一个目录
  2. Right click and open with a text editor (notepad)右键单击并使用文本编辑器(记事本)打开
  3. Find IISUrl tag and replace its content for http://localhost:(YourPortNumber)找到IISUrl 标记并将其内容替换为http://localhost:(YourPortNumber)
  4. Save and reload your project!保存并重新加载您的项目!

My issue was with Windows 10 Defender.我的问题是 Windows 10 Defender。 I had given IIS permission in the past, but seems like it is now ignoring it.我过去曾授予 IIS 权限,但现在似乎忽略了它。 Will look into it later, but for now I disabled controlled folder access and it worked.稍后会研究它,但现在我禁用了受控文件夹访问并且它起作用了。

I wanted open an exiting project of Visual Studio 2017 in VS 2019 and encountered with the same issue.我想在 VS 2019 中打开 Visual Studio 2017 的现有项目并遇到同样的问题。 I find its a version related problem.我发现它是一个与版本相关的问题。 The solution is: Create a new project in the newer VS and copy the codes from the older VS.解决方法是:在较新的VS中创建一个新项目,并从较旧的VS中复制代码。

我刚刚放弃并更新了applicationhost.config文件

尝试以管理员身份运行Visual Studio

Try decrypting the applicationhost.config file.尝试解密 applicationhost.config 文件。 That worked for me.那对我有用。

Creation of the virtual directory xxxx failed with error: Object reference not set to an instance of an instance of an object...创建虚拟目录 xxxx 失败,错误为:未将对象引用设置为对象实例的实例...

Error Screenshot This issue happened to me after deleting my local repository and downloading the repository from the cloud.错误屏幕截图在删除我的本地存储库并从云中下载存储库后,我遇到了这个问题。

Per one of the solutions above, I deleted the .vs folder with no luck.根据上述解决方案之一,我删除了 .vs 文件夹,但没有运气。 To solve the issue, I ended up mixing a couple of the solutions in this forum.为了解决这个问题,我最终在这个论坛中混合了几个解决方案。

I went to the folder .vs/SolutionName/config and pasted the applicationHost.config file from the latest subfolder on the folder C:/inetpub/history/我转到文件夹.vs/SolutionName/config并粘贴了文件夹C:/inetpub/history/上最新子文件夹中的applicationHost.config文件

After that, I restarted VS and the error disappeared.之后,我重新启动了 VS,错误消失了。

simply fix for me简单地为我修好
Close your Visual Studio关闭你的 Visual Studio

o remove .vs in .Net\\ o 在.Net\\删除.vs
o remove IISExpress in Documents o 删除Documents中的IISExpress

Reopen it, everything should be fine重新打开应该没问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 创建虚拟目录http:/ / localhost:16858 /失败,并显示以下错误 - Creation of the virtual directory http:/ /localhost:16858/ failed with the error 虚拟目录http:// localhost:1234 /的创建失败,并显示以下错误 - Creation of the virtual directory http://localhost:1234/ failed with the error 创建虚拟目录 http//localhost 失败,错误为“文件目录”。无法写入配置文件 - Creation of virtual directory http//localhost failed with the error.File name “ file directory”.Cannot write configuration file 删除错误创建的 IIS Express 中的虚拟目录 - remove virtual directory in IIS Express created in error 无法打开任何Web项目-虚拟目录创建失败 - Cannot open any Web Projects - Creation of Virtual Directory failed 创建虚拟目录后无法在Web服务器上启动调试 - Unable to start debugging on web server after creating virtual directory 仅在本地IIS服务器上支持创建虚拟目录 - Creating a virtual directory is only supported on the local IIS server 必须在每次构建之前创建虚拟目录以防止错误 - Must Create Virtual Directory Before Each Build to Prevent Error 错误:无法在视图目录中查找视图“列表” - Error: Failed to lookup view “list” in views directory 在Azure虚拟机上创建并连接到Entity Framework数据库时出错 - Error when creating and connecting to Entity Framework database on an Azure virtual machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM