与IIS 6和IIS 7兼容的应用程序C# [英] Application c# compatible with IIS 6 and IIS 7

查看:124
本文介绍了与IIS 6和IIS 7兼容的应用程序C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用IIS 6.0创建虚拟控制器和其他一些东西的类,现在我对ServerManager类进行了相同的操作,以对IIS 7x进行了相同的操作.我们需要在同一实用程序中与这两个IIS兼容. (不使用与IIS 6的兼容性)
问题在于,在IIS 6计算机中,Microsoft.Web.Administration程序集不存在.我知道不可能拥有它,因为dll仅随附IIS7.

最好的方法是什么?

谢谢!..

解决方案

我在这里看不到问题.您的第一个版本针对IIS 6,对吗?这样一来,无论如何都不会使用IIS 7特定的类.那么,为什么不将相同的代码也与IIS 7一起使用呢?

[更新]
~~~~~~~~~

回应您的评论.

如果IIS的两个版本需要两个不同的程序集/类来以编程方式进行管理,则您将无法期望有一段代码来处理此问题.

一种简化设计的方法是拥有两个单独的DLL,一个用于IIS6,另一个用于IIS7.两者都实现一个公共接口.并且您的主应用程序将始终通过此公共接口访问这些DLL,并且在运行时,您决定根据目标计算机上安装的IIS版本来加载这些DLL中的一个.


I have a class that creates a Virtual Director and some other stuff with IIS 6.0, now I did the same with the ServerManager class to do the same with IIS 7x. We need to be compatible with both IIS in the same utility. (without using the compatibility with IIS 6)
The problem is that in IIS 6 machines the Microsoft.Web.Administration assembly does not exist. I know it''s not possible to have it because the dll only comes with IIS 7.

What''s the best way to do this?

Thanks!..

解决方案

I don''t see the problem here. Your first version targets IIS 6, correct? So that one will not be using the IIS 7 specific classes anyway. So why don''t you just use that same code with IIS 7 too?

[Update]
~~~~~~~~~

In response to your comment.

If the two versions of IIS require two different assemblies/classes to manage programmatically, then there''s no way you can expect a single piece of code to handle this.

One approach to simplify your design would be to have two separate DLLs, one for IIS6 and one for IIS7. Have both implement a common interface. And your main application will always access these DLLs via this common interface, and at runtime, you decide to load either one of these DLLs depending on what version of IIS is installed on the target machine.


这篇关于与IIS 6和IIS 7兼容的应用程序C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆