我有一个控制台应用程序,用于解析输入文件并根据输入创建网站集。它由农场管理员帐户在服务器场中的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)
SharePoint\SharePointDataAccess.cs(25,0): at ImportOrgsUsers.SharePoint.SharePointDataAccess.CreateOrgSite(String path)
答案 0 :(得分:0)
我在网上看了一眼并没有找到任何确定的东西。根据您的堆栈跟踪,这些恼人的嵌入式COM对象之一显然会引发错误。我能给你的最好答案是0x80070057是COM代表“常规错误”或“无效参数”或其他相似之处。我的建议是:
String.Empty
newSiteUrl
就像他们here一样(例如“sites / mynewsite”)如果这不起作用,那么我祝你好运找到答案:(
答案 1 :(得分:0)
我知道这个问题很古老,但我认为您的问题可能是您无法主动连接到域。这是我在使用域帐户远程工作但未连接到VPN时遇到的行为。尝试创建网站时,SharePoint需要连接到域以获取有关您指定的网站所有者的信息。