When creating a new site collection using PowerShell:
New-SPSite $siteCollUrl -Name $siteCollName -Template $template -OwnerAlias $siteCollAdmin –Language $siteCollLanguage
you might get an exception:
New-SPSite : The URL '/sites/sitecollname/' is invalid. It may contain illegal characters, or be too long.
The problem is caused by the trailing slash in the new site collection URL. It should be removed.
Thursday, July 4, 2013
Tuesday, June 11, 2013
Sharepoint 2013 + EntLib 5 Validation block
Using Enterprise Library 5 with Sharepoint 2013 could be a tricky. A strange exception is thrown from Validation block of EntLib when it's used from Sharepoint:
Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type ValidatorFactory, key "" ---> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Validation.ValidatorFactory", name = "(none)". Exception occurred while: while resolving. Exception is: InvalidOperationException - The type ValidatorFactory does not have an accessible constructor. ----------------------------------------------- At the time of the exception, the container was: Resolving Microsoft.Practices.EnterpriseLibrary.Validation.ValidatorFactory,(none) ---> System.InvalidOperationException: The type ValidatorFactory does not have an accessible constructor.
The solution is to add the following configuration elements into web.config:
1. Add a section declaration into <configSections>
<section name="typeRegistrationProvidersConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.TypeRegistrationProvidersConfigurationSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.1.508.0, Culture=neutral, PublicKeyToken=3602034a0e4e3f13" />
2. Add the section into <configuration>
<typeRegistrationProvidersConfiguration>
<remove name="Validation" />
<add name="Validation" providerType="Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.ValidationTypeRegistrationProvider, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.1.508.0, Culture=neutral, PublicKeyToken=3602034a0e4e3f13" />
</typeRegistrationProvidersConfiguration>
Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type ValidatorFactory, key "" ---> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Validation.ValidatorFactory", name = "(none)". Exception occurred while: while resolving. Exception is: InvalidOperationException - The type ValidatorFactory does not have an accessible constructor. ----------------------------------------------- At the time of the exception, the container was: Resolving Microsoft.Practices.EnterpriseLibrary.Validation.ValidatorFactory,(none) ---> System.InvalidOperationException: The type ValidatorFactory does not have an accessible constructor.
The solution is to add the following configuration elements into web.config:
1. Add a section declaration into <configSections>
<section name="typeRegistrationProvidersConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.TypeRegistrationProvidersConfigurationSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.1.508.0, Culture=neutral, PublicKeyToken=3602034a0e4e3f13" />
2. Add the section into <configuration>
<typeRegistrationProvidersConfiguration>
<remove name="Validation" />
<add name="Validation" providerType="Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.ValidationTypeRegistrationProvider, Microsoft.Practices.EnterpriseLibrary.Validation, Version=5.1.508.0, Culture=neutral, PublicKeyToken=3602034a0e4e3f13" />
</typeRegistrationProvidersConfiguration>
Subscribe to:
Posts (Atom)