以编程方式创建网站集时出错

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了以编程方式创建网站集时出错相关的知识,希望对你有一定的参考价值。

我有一个控制台应用程序,将用于解析输入文件并根据输入创建网站集。它由农场管理员帐户在服务器场中的WFE上运行。尝试将网站集添加到具有有效用户的Web应用程序时,会在堆栈深处抛出ArgumentException,并显示错误消息“0x80070057”。我已经验证,如果使用了无效的帐户,则抛出指示未找到用户的正确SPException,并且所有其他参数都是正确的。

码:

    internal static void CreateOrgSite(String path)
    {
        SPWebApplication webApp = SPWebApplication.Lookup(new Uri(ConfigurationManager.AppSettings["WebAppBaseUrl"]));

        String user = Environment.UserDomainName + "\" + Environment.UserName;
        String newSiteUrl = GetCompleteUrl(path);
        webApp.Sites.Add(newSiteUrl, user, String.Empty);

    }

堆栈跟踪:

System.ArgumentException: <nativehr>0x80070057</nativehr><nativestack></nativestack>
    at Microsoft.SharePoint.Library.SPRequestInternalClass.OpenWebInternal(String bstrUrl, Guid& pguidID, String& pbstrRequestAccessEmail, UInt32& pwebVersion, String& pbstrServerRelativeUrl, UInt32& pnLanguage, UInt32& pnLocale, String& pbstrDefaultTheme, String& pbstrDefaultThemeCSSUrl, String& pbstrThemedCssFolderUrl, String& pbstrAlternateCSSUrl, String& pbstrCustomizedCssFileList, String& pbstrCustomJSUrl, String& pbstrAlternateHeaderUrl, String& pbstrMasterUrl, String& pbstrCustomMasterUrl, String& pbstrSiteLogoUrl, String& pbstrSiteLogoDescription, Object& pvarUser, Boolean& pvarIsAuditor, Int32& plSiteFlags, Boolean& pbOverwriteMUICultures, Boolean& pbMUIEnabled, String& pbstrAlternateMUICultures, Int32& puiVersion, Int16& pnClientTag)
    at Microsoft.SharePoint.Library.SPRequest.OpenWebInternal(String bstrUrl, Guid& pguidID, String& pbstrRequestAccessEmail, UInt32& pwebVersion, String& pbstrServerRelativeUrl, UInt32& pnLanguage, UInt32& pnLocale, String& pbstrDefaultTheme, String& pbstrDefaultThemeCSSUrl, String& pbstrThemedCssFolderUrl, String& pbstrAlternateCSSUrl, String& pbstrCustomizedCssFileList, String& pbstrCustomJSUrl, String& pbstrAlternateHeaderUrl, String& pbstrMasterUrl, String& pbstrCustomMasterUrl, String& pbstrSiteLogoUrl, String& pbstrSiteLogoDescription, Object& pvarUser, Boolean& pvarIsAuditor, Int32& plSiteFlags, Boolean& pbOverwriteMUICultures, Boolean& pbMUIEnabled, String& pbstrAlternateMUICultures, Int32& puiVersion, Int16& pnClientTag)
    at Microsoft.SharePoint.SPWeb.InitWebPublic()
    at Microsoft.SharePoint.SPWeb.get_ServerRelativeUrl()
    at Microsoft.SharePoint.SPWeb.get_Url()
    at Microsoft.SharePoint.SPUser.InitMember()
    at Microsoft.SharePoint.SPUser..ctor(SPWeb web, SPSecurableObject scope, String strIdentifier, Object[,] arrUsersData, UInt32 index, Int32 iByParamId, String strByParamSID, String strByParamEmail, SPUserCollectionType userCollectionType, Boolean isSiteAuditor)
    at Microsoft.SharePoint.SPUser..ctor(SPWeb web, SPSecurableObject scope, String strIdentifier, Object[,] arrUsersData, UInt32 index, Int32 iByParamId, String strByParamSID, String strByParamEmail, SPUserCollectionType userCollectionType)
    at Microsoft.SharePoint.SPUserCollection.GetByLoginNoThrow(String loginName)
    at Microsoft.SharePoint.SPUserCollection.get_Item(String loginName)
    at Microsoft.SharePoint.Administration.SPSiteCollection.Add(SPContentDatabase database, SPSiteSubscription siteSubscription, String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin, String secondaryContactName, String secondaryContactEmail, String quotaTemplate, String sscRootWebUrl, Boolean useHostHeaderAsSiteName)
    at Microsoft.SharePoint.Administration.SPSiteCollection.Add(SPSiteSubscription siteSubscription, String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin, String secondaryContactName, String secondaryContactEmail, Boolean useHostHeaderAsSiteName)
    at Microsoft.SharePoint.Administration.SPSiteCollection.Add(String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin, String secondaryContactName, String secondaryContactEmail, Boolean useHostHeaderAsSiteName)
    at Microsoft.SharePoint.Administration.SPSiteCollection.Add(String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail, String secondaryContactLogin, String secondaryContactName, String secondaryContactEmail)
    at Microsoft.SharePoint.Administration.SPSiteCollection.Add(String siteUrl, String title, String description, UInt32 nLCID, String webTemplate, String ownerLogin, String ownerName, String ownerEmail)
    SharePointSharePointDataAccess.cs(25,0): at ImportOrgsUsers.SharePoint.SharePointDataAccess.CreateOrgSite(String path)
答案

我看着网上,没有找到任何确定的东西。根据您的堆栈跟踪,这些恼人的嵌入式COM对象之一显然会引发错误。我能给你的最好答案是0x80070057是COM代表“常规错误”或“无效参数”或其他相似之处。我的建议是:

  • 放入有效的电子邮件地址而不是String.Empty
  • 格式化newSiteUrl就像他们做here(例如“sites / mynewsite”)

如果这不起作用,那么我祝你好运找到答案:(

另一答案

我知道这个问题很古老,但我认为您的问题可能是您无法主动连接到域。这是我在使用域帐户远程工作但未连接到VPN时遇到的行为。尝试创建网站时,SharePoint需要连接到域以获取有关您指定的网站所有者的信息。

以上是关于以编程方式创建网站集时出错的主要内容,如果未能解决你的问题,请参考以下文章

保存以编程方式为片段创建的视图并在 onresume 中恢复

以编程方式创建 MapView 并添加标记导致片段中出现空指针异常

创建训练时显示的数据集时出错?

以编程方式自动布局垂直ios时出错

以编程方式将按钮添加到片段

FxCop Nant 任务错误:创建文件集时出错