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.

4 comments:
This error happened to me after an initial install and only changing the default instance of http://machinename:port/ to http://localhost/
It never loads the start page
http://machinename:17001/Templates/RelatePlus/Pages/Start.aspx?id=3
Steven
I forgot to mention that those dlls were there as I had not rebuilt anything yet..
there's an EPiserver article at http://world.episerver.com/Forum/Pages/Thread.aspx?id=26853&epslanguage=en&pageIndex=2
that solved my issue.
in brief:
In web.config, changing
globalization culture="en-US" ...
to
globalization culture="en-GB" ...
The build settings are noted.. I'll look out for that next. My suspicion is that its' only on 'clean' that it would happen.. The same happened to me with EpiMail before..
This might be related and have not had a chance to investigate. When clicking on the 'Members' page a script error appears in the bottom bar of IE. not very useful err description. "Line 2 char 1 syntax err." ( That standard non descriptive script err) any clue..?
Post a Comment