Note that there are some explanatory texts on larger screens.

plurals
  1. POOperation is not valid due to the current state of the object?
    primarykey
    data
    text
    <p>I have written following code in visual stuadio 2008 to crete a new web application in sharepoint programmatically and getting following error like "Operation is not valid due to current state of the object" under invalidOperationException.</p> <pre><code>using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using Microsoft.SharePoint.Administration; using Microsoft.SharePoint; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SPSecurity.RunWithElevatedPrivileges(delegate() { SPWebApplicationBuilder webAppBuilder = new SPWebApplicationBuilder(SPFarm.Local); SPWebApplication newApplication; int myPort = 20002; webAppBuilder.Port = myPort; webAppBuilder.RootDirectory = new System.IO.DirectoryInfo("C:\\Inetpub\\wwwroot\\wss\\VirtualDirectories\\" + myPort); webAppBuilder.ApplicationPoolId = "AppPool1"; // application pool webAppBuilder.ApplicationPoolUsername = "Anant_Raj"; System.Security.SecureString password = new System.Security.SecureString(); string strName = "#ana123"; char[] pass = strName.ToCharArray(); foreach (char c in pass) password.AppendChar(c); webAppBuilder.ApplicationPoolPassword = password; webAppBuilder.CreateNewDatabase = true; // Create new database webAppBuilder.DatabaseName = "wss_site2011_content"; // database name webAppBuilder.DatabaseServer = webAppBuilder.DefaultZoneUri.Host; //Host name/computer name webAppBuilder.UseNTLMExclusively = true; // Use NTLM authentication webAppBuilder.AllowAnonymousAccess = true; newApplication = webAppBuilder.Create(); // Create new web application newApplication.Provision(); //Provision it into web farm }); } } </code></pre> <p>Any suggestion?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload