Thursday, March 26, 2009

EPiServer Mail 4.4 and the correct version of EPiServer Shared

Over the last period of time, or actually since the 4.4 release of EPiServer Mail about a month ago, I have been asked quite a few question regarding the compatibility with EPiServer CMS R2 SP1. The main reason is that people have gotten the following error when trying to run the installer.

An unhandled error has occured:
A parameter cannot be found that matches parameter name 'SourceAssemblyName'.
When executing
 
 
At C:\Program Files\EPiServer\Mail\4.4.0.141\Install\System Scripts\Install Sit
e (No Database).ps1:202 char:80
+     Add-EPiAssemblyRedirect -TargetFilePath $webConfigFilePath -SourceAssemblyNa
me  <<<< "System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyTok
en=31bf3856ad364e35" -OldVersion "1.0.61025.0"
 
An error has occured and the transaction will be rolled back
Rolledback
 
An unhandled error has occured:
A parameter cannot be found that matches parameter name 'SourceAssemblyName'.
When executing
 
 
At C:\Program Files\EPiServer\Mail\4.4.0.141\Install\System Scripts\Install Sit
e (No Database).ps1:202 char:80
+     Add-EPiAssemblyRedirect -TargetFilePath $webConfigFilePath -SourceAssemblyNa
me  <<<< "System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyTok
en=31bf3856ad364e35" -OldVersion "1.0.61025.0"
 
Error - System.Management.Automation.ParameterBindingException: A parameter cannot be found that matches parameter name 'SourceAssemblyName'.
   at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed()
   at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
   at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
   at System.Management.Automation.CommandProcessor.BindCommandLineParameters(CommandParameterInternal[] parameters)
   at System.Management.Automation.CommandProcessor.Prepare(CommandParameterInternal[] parameters)
   at System.Management.Automation.CommandProcessorBase.DoPrepare(CommandParameterInternal[] parameters)
   at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorResults, Boolean enumerate)

This is because the wrong version of EPiServer Shared components are installed on the machine. The version of EPiServer Shared are determined by the order you have installed the products and NOT by the order you deployed them with EPiServer Deployment Center. The version of Shared was updated with the SP 1 release of CMS and then again with the release of EPiServer Mail 4.4.

The solution

The latest version of EPiServer Shared, and currently the only version that is working with EPiServer Mail 4.4, is version 1.1.0.71. Take a look in “Programs and Features” to see which version you have installed.

ProgramsAndFeaturesMail

If you have another version simply run the EPiServerShared.msi found in the EPiServer Mail 4.4 download. This will upgrade the Shared components.

Updated!
If you have another version, the easiest is to uninstall that version and then run the EPiServerShared.msi found in the EPiServer Mail 4.4 download. This will upgrade the Shared components. Alternatively follow the steps Paul describes in the comment below. Thanks for the help Paul!

Note: If you run the CMS R2 SP 1 installer after EPiServer Mail 4.4, this will downgrade EPiServer Shared. Simple follow the steps above again to make Mail work again.

Wednesday, March 18, 2009

EPiServer Days 2009 Retrospective

A bit more than a week has passed since the great EPiServer Days was hosted in Stockholm, Sweden. It was two days packed with amazing stuff such as keynotes, technical seminars, not-so-technical seminars and heaps of partners and customers – great times! I think that almost everyone who attended the event thought it was time well spent.

The first day was hosted at Kistamässan, this was the main event day with keynotes and short general sessions. I did a 30 minutes talk about “How to develop an online community”. I think the session went well, even though it’s hard to say something useful about such a wide topic in just 30 minutes. Despite this I hope that everyone got something to think about in their next community project.

When I started to work on my presentation my first assumption was to look at from a developer’s point of view. But I quickly realized that a lot of the things to think about when heading into a community project is things not usually handled by a developer. However my experience tells me that these things are to complex for the ordinary project leader, and thereby I think it’s best if the developers step up and take some extended responsibility to make sure you don’t step  into one of the community pitfalls. So I decided to target my presentation to this “more responsible developer”.

I spent great deal of session talking about the difference between a traditional website and a community. I think this is the single most important thing to know when developing a community, especially for people who have mostly worked with classic CMS sites in the past. The main idea is to consider the difference between pages and objects, editors and moderators, editors and users, visitors and users, etc.

I made my slides available through SlideShare below. I’m sorry to say to all the international readers, the slides are in Swedish since the session was given in Swedish.

I also did a session day two of the EPiServer Days 2009, this time together with Johan Björnfot – a colleague at EPiServer. More about this session in a later blog post.

By the way, check out the all the tweets connected to the EPiServer Days here.

EPiServer has now made all of the material from the days available for download at the World website. My presentation in PDF from the first day can be found here, note that the slides are in Swedish.

Monday, March 16, 2009

InvalidOperationException in Relate+

After getting a number of comments in mail and in forums from people having trouble with a fresh installation of a EPiServer Relate+ site, I decided to make a blog post dedicated to it.

The problem appear as an error that look something like the one below when trying to access the site.

Exception details:  InvalidOperationException: Failed to compare two elements in the array.
 
Stack trace:
 
[InvalidOperationException: Failed to compare two elements in the array.]
   at System.Array.SorterObjectArray.SwapIfGreaterWithItems(Int32 a, Int32 b)
   at System.Array.SorterObjectArray.QuickSort(Int32 left, Int32 right)
   at System.Array.Sort(Array keys, Array items, Int32 index, Int32 length, IComparer comparer)
   at System.Collections.ArrayList.IListWrapper.Sort(Int32 index, Int32 count, IComparer comparer)
   at EPiServer.Common.Modules.ModuleCollection.Sort(IComparer comparer)
   at EPiServer.Common.Settings.LoadModules()
   at EPiServer.Common.Settings.LoadSettings()
   at EPiServer.Common.Web.Global.OnBeginRequest()
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
 
[Inner exception TargetInvocationException: Exception has been thrown by the target of an invocation.]
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at EPiServer.Common.ObjectComparer.GetPropertyValue(Object o, String propertyPath)
   at EPiServer.Common.ObjectComparer.Compare(Object x, Object y)
   at System.Array.SorterObjectArray.SwapIfGreaterWithItems(Int32 a, Int32 b)

This problem will occur whenever “Clean” or “Rebuild” is used in Visual Studio. These operations will remove all non-referenced assemblies from the bin directory. Since some of the assemblies that are needed to make the site work are not referenced in the project file of the solution you will get the error above.

One may argue the these assemblies should be referenced since they are you used by the assemblies that are referenced. On the other hand if one do this, the memory consumption of the site would go up. But luckily there is an easy solution that is better!

First we need to know which assemblies that are not referenced. After some investigation you will come up with this list:

  • Castle.DynamicProxy.dll
  • EPiserver.Community.VideoGallery.XmlSerializers.dll
  • Iesi.Collections.dll
  • Microsoft.Practices.EnterpriseLibrary.Common.dll
  • Microsoft.Practices.EnterpriseLibrary.Data.dll
  • Microsoft.Practices.ObjectBuilder.dll
  • NHibernate.dll

Create a directory at the solution root and call it “Dependencies” – or whatever you like to call it - and add the assemblies listed above to the dependencies directory. Open your EPiServer.Templates.RelatePlus.csproj file with your favorite text editor, e.g. Notepad. Scroll down to the end of the file add the following code at the same level as “ProjectExtensions”:

<Target Name="AfterBuild">
  <ItemGroup>
    <RelatePlusDependencies Include="$(MSBuildProjectDirectory)\Dependencies\*.dll" />
  </ItemGroup>
  <Copy SourceFiles="@(RelatePlusDependencies)" DestinationFolder="$(MSBuildProjectDirectory)\bin" />
</Target>

Save the file and hit Rebuild in Visual Studio.

This is a MSBuild task that will simple copy the assemblies from the “Dependencies” directory to the “bin” directory after each build is done. After adding this you will no longer have problem with missing assemblies in your bin directory and your site will work after every Rebuild!

For more information about MSBuild, see the reference at http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx.