我正在尝试使用C#中的Microsoft.Web.Administration dll在IIS中创建一个站点。我正在使用以下代码
using (var serverManager = new ServerManager())
{
ApplicationPool pool = serverManager.ApplicationPools.Add(ClientDomain);
pool.ManagedRuntimeVersion = "v4.0";
Site site = serverManager.Sites.Add(SiteName, httpProtocol, httpBindingInformation, physicalPath);
site.Bindings.Add(httpsBindingInformation, httpsProtocol);
serverManager.CommitChanges();
}
我遇到异常"方法或操作没有实现"当我从asp.net项目运行代码但是如果从控制台项目运行相同的代码,它工作正常。以下是异常的详细信息
at Microsoft.Web.Administration.Interop.IAppHostProperty.get_Value()
at Microsoft.Web.Administration.ConfigurationElement.GetPropertyValue(IAppHostProperty property)
at Microsoft.Web.Administration.ConfigurationElement.GetAttributeValue(String attributeName)
at Microsoft.Web.Administration.Binding.get_CertificateHash()
at Microsoft.Web.Administration.BindingCollection.Add(Binding binding)
at Microsoft.Web.Administration.BindingCollection.Add(String bindingInformation, String bindingProtocol)
at TestProject.BLL.CRMSiteManagement.CRMSiteIISSetup.Process() in e:\CRMSiteManagement\CRMSiteIISSetup.cs:line 35
at TestProject.BLL.CRMSiteManagement.CRMSiteService.CreateNewCRMSite(CRMSite newSite) in e:CRMSiteManagement\CRMSiteService.cs:line
似乎是一个权利问题,但我不知道如何解决它。 更新1: 错误发生在localhost上的以下代码行
site.Bindings.Add(httpsBindingInformation, httpsProtocol);
答案 0 :(得分:1)
我认为您正在尝试两次设置相同的绑定:
printf("%s\n", gl->wsk_u->imie);
Site site = serverManager.Sites.Add(SiteName, httpProtocol, httpBindingInformation, physicalPath);