简体   繁体   English

从控制台应用程序访问虚拟目录

[英]Accessing Virtual Directory from console application

i have console application in which it will try to access an application installed in IIS (ie virtual directory) for getting the db connection information. 我有控制台应用程序,它将尝试访问IIS中安装的应用程序(即虚拟目录)以获取数据库连接信息。 While doing this in windows xp (IIS 5.1), it is working, but it is not working in windows 7 (IIS 7.5). 在Windows XP(IIS 5.1)中执行此操作时,它正在工作,但在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. 控制台应用程序的Target .Net框架是2.0、3.5(具有5个应用程序),因为它是几年前开发的。 Now trying to move from XP to Win 7, but facing some issues with accessing the IIS folder. 现在尝试从XP迁移到Win 7,但是在访问IIS文件夹时遇到一些问题。 Please advise to access the virtual directory folder in win 7. Any code example will help a lot. 请建议访问win 7中的虚拟目录文件夹。任何代码示例都会有很大帮助。

* Error: *System.Runtime.InteropServices.COMException (0x80070005): Access is denied. * 错误: * System.Runtime.InteropServices.COMException(0x80070005):访问被拒绝。

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. 如果尝试访问Windows 7中与虚拟目录关联的物理目录,则可能是在没有足够特权的情况下运行控制台应用程序。 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 . 在检查完代码后,我发现您正在使用目录服务来访问IIS 7,因此请确保在该计算机上安装了IIS Metabase和IIS 6配置兼容性 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. 在Windows 7中,可以在控制面板->程序->程序和功能->关闭Windows功能中找到它,然后转到Internet信息服务-> Web管理工具-> IIS 6管理兼容性。 You need to enable the check in IIS Metabase and IIS 6 configuration compatibility 您需要启用IIS Metabase和IIS 6配置兼容性检查

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. 但是,从代码访问和管理IIS 7的建议方法是使用Microsoft.Web.Administration库中提供的IIS管理API 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? 如何使用C#代码获取IIS虚拟目录和Web应用程序的物理路径?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM