diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs index 094e177076..f7c41a1b43 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs @@ -45,10 +45,8 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels } break; case WebServer.IIS: - if (WebProjectService.IISVersion == IISVersion.IIS5 || - WebProjectService.IISVersion == IISVersion.IIS6 || - WebProjectService.IISVersion == IISVersion.IIS7 || - WebProjectService.IISVersion == IISVersion.IIS_Future) { + if (WebProjectService.IISVersion != IISVersion.IISExpress && + WebProjectService.IISVersion != IISVersion.None) { UseLocalIIS.IsChecked = true; ProjectUrl.Text = CurrentProjectDebugData.ProjectUrl ?? string.Empty; @@ -134,9 +132,8 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels WebProjectDebugData data = new WebProjectDebugData(); data.WebServer = WebServer.IIS; data.Port = string.Empty; - bool isIISInstalled = WebProjectService.IISVersion == IISVersion.IIS5 || - WebProjectService.IISVersion == IISVersion.IIS6 || - WebProjectService.IISVersion == IISVersion.IIS7; + bool isIISInstalled = WebProjectService.IISVersion != IISVersion.IISExpress && + WebProjectService.IISVersion != IISVersion.None; if (!isIISInstalled) { StatusLabel.Text = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound"); diff --git a/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs b/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs index 639ef591fb..a674c126dd 100644 --- a/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs +++ b/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs @@ -7,6 +7,7 @@ using System.IO; using System.Reflection; using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Dom; using Microsoft.Win32; namespace ICSharpCode.SharpDevelop.Project @@ -14,11 +15,12 @@ namespace ICSharpCode.SharpDevelop.Project public enum IISVersion { None = 0, + IISExpress, IIS5 = 5, IIS6, IIS7, - IISExpress, - IIS_Future + IIS8, + IIS_Future = 100 } public enum WebServer @@ -49,7 +51,7 @@ namespace ICSharpCode.SharpDevelop.Project /// /// Gets "iisexpress" string. /// - public const string IIS_EXPRESS_PROCESS_NAME = "iisexpress"; + public const string IIS_EXPRESS_PROCESS_NAME = "iisexpress"; /// /// Gets "aspnet_wp" string. @@ -193,8 +195,9 @@ namespace ICSharpCode.SharpDevelop.Project public static string CreateVirtualDirectory(string virtualDirectoryName, string physicalDirectoryPath) { try { + string iisNotFoundError = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound"); if (!IsIISInstalled) - return ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound"); + return iisNotFoundError; string error; @@ -208,20 +211,26 @@ namespace ICSharpCode.SharpDevelop.Project virtualDirectoryName, out error); break; - + case IISVersion.None: + return iisNotFoundError; default: - // TODO: find a better way to create IIS 7 applications without Microsoft.Web.Administration.ServerManager + // TODO: find a better way to create IIS applications without Microsoft.Web.Administration.ServerManager string name = "/" + virtualDirectoryName; - // load from GAC - IIS7 is installed - Assembly webAdministrationAssembly; + // load from GAC + Assembly webAdministrationAssembly = null; try { - // iis 7 - webAdministrationAssembly = Assembly.Load("Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); - } - catch { - // iis express - webAdministrationAssembly = Assembly.Load("Microsoft.Web.Administration, Version=7.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); + // iis installed + foreach(var assembly in GacInterop.GetAssemblyList()) { + if (assembly.FullName.Contains("Microsoft.Web.Administration")) { + webAdministrationAssembly = Assembly.Load(assembly.FullName); + break; + } + } + } catch { + return iisNotFoundError; } + if (webAdministrationAssembly == null) + return iisNotFoundError; // use dynamic because classic reflection is way TOO ugly dynamic manager = webAdministrationAssembly.CreateInstance("Microsoft.Web.Administration.ServerManager");