Windows 2003 서버를 사용하여 다양한 작업을 실행합니다. 이러한 작업 중 일부는 IIS 6 (실행, 시작, 중지)을 실행하는 웹 서버에 응용 프로그램 풀 명령을 보냅니다. 이제 IIS 7을 실행하는 Windows 2008 웹 서버가 있으며 동일한 명령을 보내려고합니다. 이것은 모두 C#을 사용하여 완료됩니다. Windows 2003 서버에서 프로그래밍 방식으로 IIS 7 서버 제어
이
우리가 IIS 6에 대한 명령을 보낼 때 사용하는 코드입니다 :var methodToInvoke = "Stop"; // could be "Stop", "Start", or "Recycle"
var co = new ConnectionOptions
{
Impersonation = ImpersonationLevel.Impersonate,
Authentication = AuthenticationLevel.PacketPrivacy
};
var objPath = string.Format("IISApplicationPool.Name='W3SVC/AppPools/{0}'", appPoolName);
var scope = new ManagementScope(string.Format(@"\\{0}\root\MicrosoftIISV2", machineName), co);
using (var mc = new ManagementObject(objPath))
{
mc.Scope = scope;
mc.InvokeMethod(methodToInvoke, null, null);
}
이 코드 때문에 기본 변화에 IIS 7 작동하지 않습니다, 그래서 우리는 현재이하려는 :
using (ServerManager serverManager = ServerManager.OpenRemote(machineName))
{
var appPool = serverManager.ApplicationPools[appPoolName];
if (appPool != null)
{
appPool.Stop(); // or app.Start() or app.Recycle()
serverManager.CommitChanges();
}
}
을
위의 코드는 Windows 7 (및 IIS 7.5)을 실행하는 내 워크 스테이션에서 정상적으로 작동합니다. 그러나이 코드를 응용 프로그램 서버에 배포하면 작동하지 않습니다. 때문에 7은 윈도우 서버 2003 서버에서 사용할 수 없습니다 IIS 사실을
내 연구에서System.InvalidCastException:
Unable to cast COM object of type 'System.__ComObject' to interface type
'Microsoft.Web.Administration.Interop.IAppHostWritableAdminManager'.
This operation failed because the QueryInterface call on the COM component for the
interface with IID '{FA7660F6-7B3F-4237-A8BF-ED0AD0DCBBD9}' failed due to the following error:
Interface not registered (Exception from HRESULT: 0x80040155).
, 이것이다 : 그것은이 오류가 발생합니다. (필자는 Microsoft.Web.Administration.dll 파일을 포함했다.)
그래서 내 질문은 : IIS 7 위의 코드는 윈도우 2003 서버에서 모든 작업 할 수
- 이 가능합니까?
- # 1에 없다면 더 나은 방법이 있습니까?
웹 서버 자체에서 해당 서버의 응용 프로그램 풀을 시작/중지/재활용하는 웹 서비스가 만들어졌습니다. 이 웹 서비스는 분명히 업데이트 할 앱 풀과 별도의 앱 풀에 있어야합니다. 매우 안전한 솔루션은 아니지만 내부 웹 서버로 작업하고 있습니다. –
같은 문제로 인해 게시글에서 내가 뭘 두려워했는지 확인했습니다. 관리 API는 Windows XP에서 작동하지 않습니다. 게시물을 주셔서 감사합니다 – Jeremy