Skip to content

SPSite.OpenWeb error: ‘url’ contains illegal character

The SPSite.OpenWeb(webUrl) method does not like when it is called with an url parameter that is url encoded.

Imagine that a user created a new site which is called “My new site”. The url that you see in the browser when you open this site will be something like http://server/sites/My%20new%20site
If you pass this url to the OpenWeb, then it will throw an exception, saying that the url contains illegal characters (%).

Note, that for example Uri.AbsolutePath returns urlencoded path which can contain illegal characters. So you should not pass it directly to OpenWeb but make sure that the “%20” and other encoded parts are converted back to the original characters.

Advertisements

Unable to add selected web part(s). … : Cannot import … Web Part.

When adding a custom webpart to a page, we received the following error:

—————————
Message from webpage
—————————
Unable to add selected web part(s).

webpart name: Cannot import webpart name Web Part.
—————————
OK
—————————

This is a quite common error messages and very uninformative. We started troubleshooting using the tips we found by google, but non of them seemed to be related to our problem. The most interesting part of the story was that the same webpart had no problem until a couple of days ago. And there were no changes in the webpart definition or any other part of the code, that could have caused such problem.
Some instances of the same webpart were already on some pages and they were working without any problem. We just could not add a new instance of the webpart to the page.

In the ULS logs we found the following related error:

Error importing WebPart. Assembly xx.xx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4f6f772418ff3333, TypeName. xx.xx.xx
Failed to add webpart http://server/_catalogs/wp/webpart name.webpart;webpart name.
Exception Microsoft.SharePoint.WebPartPages.WebPartPageUserException: Cannot import Web Part.
at Microsoft.SharePoint.WebPartPages.WebPartImporter.CreateWebPart(Boolean clearConnections)
at Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager manager, XmlReader reader, Boolean clearConnections, Uri webPartPageUri, SPWeb spWeb)
at Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager manager, XmlReader reader, Boolean clearConnections, SPWeb spWeb)
at Microsoft.SharePoint.WebPartPages.WebPartQuickAdd.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)

We doublechecked and triplechecked the assebly definition, PublicKeyTokens, the assemblies in the GAC – everything was ok.

We had a last known good version in source control, so we had no better idea than rolling back the changes to find the point where things got broken.

And we found this line of code added to one of the underlying logging components that was used by the webpart:

...
Assembly a = Assembly.GetExecutingAssembly();
...

When we removed this line, the webpart problem was resolved. Great!

After further testing we found that this line threw the following exception:

[4928] System.Security.SecurityException: Request for the permission of type ‘System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed.
[4928] at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
[4928] at System.Security.CodeAccessPermission.Demand()
[4928] at System.Reflection.Assembly.get_Location()

I’m still not sure why this error came up only when adding a webpart to a page. And how is it possible that it caused no problem in the other 99.9999% of the site.

But I don’t care now. Happy to have it resolved…

Funny SharePoint videos

SharePoint Cup of Chaos

Begging for Approval

The Elusive Chris Smith

TFS 2010 Build Agent unavailable, stuck in Initializing… status

The first simptom of the problem was that our TFS team builds started to fail with the error message;

TF215097: An error occurred while initializing a build for build definition \My Project\Nightly build: The message with To ‘http://servername:9191/Build/v3.0/Services/Controller/4’ cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver’s EndpointAddresses agree.

After a bit of troubleshooting, we found that the build agents are in Unavailable status in the Visual Studio Team Explorer.

The Team Foundation Server Administration Console showed that the Agents stuck in the Initializing… status, restarting both the controller and the agents did not help.

Looking at the event log of the server where the agents are installed however showed an interesting error message:

Service ‘agent name’ failed. Details:
Exception Message: TF205022: The following path contains more than the allowed 259 characters: C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\BuildAgent\Source\…. Specify a shorter path. (type InvalidPathException)

In fact, there were some files in the source code quite deep in the folder hierarchy, and when TFS appended the path of the Temp folder to them, they exceeded the 259 characters.

Having no better idea, we moved these files into another folder, closer to the root. After this was done and the changes were checked in and we restarted both the Build Controller and the Build Agents – everything went back to normal.

Creating loops in SharePoint Designer 2013

In SharePoint Designer 2010 it was not possible to create loops in workflows (or only in a quite painful way…). In SharePoint Designer 2013 there is a new Loop activity which supports looping.

Let’s crate a new site workflow to test it. Make sure that the Platform Type of the workflow is set to SharPoint 2013 Workflow otherwise looping will not be available.

If only SharPoint 2010 Workflow is listed in the dropdown, then you don’t have the new Windows Azure Workflow platform installed. It is not straightforward how to install it, check out this article for instructions: http://msdn.microsoft.com/en-us/library/jj163276.aspx

From the ribbon, let’s add one of each loop type to the designer

and add some test actions into the body of the loop
(note that I created two numeric initiation parameters for the workflow to set the number of iterations, but you can just hard-code some numbers)

That’s all. Save and Publish the workflow to test it.
You can start your workflow from the Site Workflows page of your site (reachable form the View Site Contents page)

Could not successfully create management Service Bus entity ‘WF_Management/WFTOPIC’ with multiple retries within timespan of …

To enable SharePoint 2013 workflows on SharePoint 2013, the Windows Azure Workflow Installer must be downloaded and the Workflow component must be installed. After successful installation, the Windows Azure Workflow Configuration Wizard needs to be run to set up the workflow engine, but it may fail with the following exception:

System.Management.Automation.CmdletInvocationException: Could not successfully create management Service Bus entity ‘WF_Management/WFTOPIC’ with multiple retries within timespan of 00:02:05.6894775. —> System.TimeoutException: Could not successfully create management Service Bus entity ‘WF_Management/WFTOPIC’ with multiple retries within timespan of 00:02:05.6894775. —> System.UnauthorizedAccessException: The remote server returned an error: (401) Unauthorized. Authorization failed for specified action: Manage..TrackingId:511deade-c3a6-4393-a08f-816b15fb826a,TimeStamp:7/30/2012 8:54:59 AM —> System.Net.WebException: The remote server returned an error: (401) Unauthorized.

There are two things to check here:

First, make sure that the service account that you specified in the begining of the wizard is a Local Administrator on your server and member of the sysadmin Server Role on the SQL Server.

Second, make sure that you specified the service account with the FQDN domain name (like user@domain.com, and not just user@domain)

To resolve the error, you will need to

  1. run the Workflow Configuration wizard lo leave the farm
  2. delete the following databases on the SQL Server
    • SbGatewayDatabase
    • SbManagementDB
    • SBMessageContainer01
    • WFInstanceManagementDB
    • WFManagementDB
    • WFResourceManagementDB
  3. run the Workflow Configuration wizard to create a new farm. (make sure you use the full domain name for the Service Account)

The complete error message:

Processing completed
Validating input and configuration parameters.
Installing auto generated certificate.
Granting ‘Log on as Service’ privilege to the run as account.
Workflow configuration starting.
Configuring workflow runtime settings.
System.Management.Automation.CmdletInvocationException: Could not successfully create management Service Bus entity ‘WF_Management/WFTOPIC’ with multiple retries within timespan of 00:02:05.6894775. —> System.TimeoutException: Could not successfully create management Service Bus entity ‘WF_Management/WFTOPIC’ with multiple retries within timespan of 00:02:05.6894775. —> System.UnauthorizedAccessException: The remote server returned an error: (401) Unauthorized. Authorization failed for specified action: Manage..TrackingId:511deade-c3a6-4393-a08f-816b15fb826a,TimeStamp:7/30/2012 8:54:59 AM —> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.ServiceBusResourceOperations.CreateOrUpdateAsyncResult`1.EndGetResponse(CreateOrUpdateAsyncResult`1 thisPtr, IAsyncResult ar)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
— End of inner exception stack trace —

Server stack trace:

Exception rethrown at [0]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.NamespaceManager.CreateOrUpdateTopicAsyncResult.CreateDescription(CreateOrUpdateTopicAsyncResult thisPtr, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)

Exception rethrown at [1]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.Workflow.Management.ManagementEntitiesCreator.CreateManagementEntitiesAsyncResult.EndCreateTopic(IAsyncResult result)
at Microsoft.Workflow.Common.BackoffRetryAsyncResult.IsolateWithRetry(IAsyncResult result)
— End of inner exception stack trace —
at Microsoft.Workflow.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.Workflow.Administration.ServiceUpdateManager.CreateManagementEntities(IList`1 namespaceManagerUris, ServiceBusClientCredentialType clientCredentialType, IDictionary`2 arguments, TimeSpan retryTimeout)
at Microsoft.Workflow.Deployment.Commands.WorkflowServiceConfigHelper.SetWFRuntimeSettings(String resourceDBConnectionString, String config)
at Microsoft.Workflow.Deployment.Commands.AddWFHost.CallWFRuntimeSettings(Service wfserviceInfo)
— End of inner exception stack trace —
at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
at Microsoft.Workflow.Deployment.ConfigWizard.CommandletHelper.InvokePowershell(Command command, Action`2 updateProgress)
at Microsoft.Workflow.Deployment.ConfigWizard.ProgressPageViewModel.AddWFNode(FarmCreationModel model, Boolean isFirstCommand)

Azure Workflow: System.Management.Automation.CmdletInvocationException: A network-related or instance-specific error occurred while establishing a connection to SQL Server.

To enable SharePoint 2013 workflows on SharePoint 2013, the Windows Azure Workflow Installer must be downloaded and the Workflow component must be installed. After successful installation, the Windows Azure Workflow Configuration Wizard needs to be run to set up the workflow engine, but it may fail with the following exception:

System.Management.Automation.CmdletInvocationException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)

The problem here is that the Azure Workflow requires TCP/IP communication with the SQL Server, which is disabled by default.

Go to the SQL Server Configuration Manager and enable TCP/IP to resolve this error. (Of course this applies to a dev/test environments. Be aware of the security implications…)

SQL Server Configuration Manager

This is the full log related to this error:

Starting
Created and configured Service Bus farm management database.
Created and configured Service Bus gateway database.
Creating default container.
System.Management.Automation.CmdletInvocationException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server) —> System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server) —> System.ComponentModel.Win32Exception: Access is denied
— End of inner exception stack trace —
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at Microsoft.ServiceBus.Commands.Common.Utility.CreateDatabase(String connectionString, Boolean throwIfExists)
at Microsoft.ServiceBus.Commands.NewSBMessageContainerCommand.CreateMessageContainerDatabase()
— End of inner exception stack trace —
at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
at Microsoft.Workflow.Deployment.ConfigWizard.CommandletHelper.InvokePowershell(Command command, Action`2 updateProgress)
at Microsoft.Workflow.Deployment.ConfigWizard.ProgressPageViewModel.CreateSBFarm(FarmCreationModel model)

SharePoint 2013 Preview – first impressions, screenshots

Ok, so finally I also have the SharePoint 2013 Preview running 🙂

The installation hasn’t changed much. As far as I can remember, the very same steps were necessary as for SharePoint 2010.

I used the following virtual environment for testing:

  • Windows Server 2012 Datacenter Edition RC (with Active directory (promoted to AD), Application Server and IIS roles active)
  • SQL Server 2012 Developer Edition
  • SharePoint Server 2013 Preview

And here are some typical SharePoint screens in the 2013 version:

Error when opening Project Server task with attached document

The following error message comes up in Project Server when opening a task which has a document attachment:

System.Web.Services.Protocols.SoapException: ProjectServerError(s) LastError=GeneralUnhandledException Instructions: Pass this into PSClientError constructor to access all error information
at Microsoft.Office.Project.Server.WebService.PWA.StatusingReadWssLinksForTask(Guid projectUid, Guid taskUid) at Microsoft.Office.Project.Server.WebServiceProxy.PSIProxyBase.InvokePSI(String serviceName, String methodName, Object[] parameters)
at Microsoft.Office.Project.Server.WebServiceProxy.PWA.StatusingReadWssLinksForTask(Guid projectUid, Guid taskUid)
at Microsoft.Office.Project.PWA.ApplicationPages.DetailsPage.InitAttachments()
at Microsoft.Office.Project.PWA.ApplicationPages.DetailsPage.PJWebPage_OnLoad(EventArgs e)
at Microsoft.Office.Project.PWA.PJWebPage.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The reason for this error is that Project Server apparently can’t handle project task attachments which are not into the “Project Documents” document library. If a document from any other document library is attached to the task then this error is thrown when someone tries to open that task.

So as a workaround, only attach a document to a task if the document is in the “Project Documents” .

UPDATE

Found workaround:

  1. Create a Choice column with the name “Status” in the document library
  2. Edit the properties of the document that you want to attach, fill the Status field.
  3. Documents where the Status field is not empty can be attached to tasks.

An installation package for the product Microsoft SharePoint Foundation 2010 1033 Lang Pack cannot be found.

Something happened to my SharePoint dev environment. Strange error messages started to pop up about missing assemblies and wrong assembly versions. When trying to Repair the installation form the Control Panel – Programs and Features the following error occured:

Microsoft SharePoint Server 2010

Microsoft SharePoint Server 2010 configuration did not complete successfully.

An installation package for the product Microsoft SharePoint Foundation 2010 1033 Lang Pack cannot be found. Try the installation again using a valid copy of the installation package ‘wssmui.msi’

Close

Tried to launch the setup form the original installer image as well to Repair the installation but the same error occured.
The solution was to uninstall and reinstall SharePoint completely. The reinstallation completed successfully and is it working now without problems.

Of course I used the same install package for both the original and the new installation so this error message probably has nothing to do with the actual problem.