ListPicker crash - xaml

I have a ListPicker with the following structure:
toolkit:ListPicker x:Name="mListPicker" HorizontalAlignment="Right" Margin="0,75,43,0" Width="100" VerticalAlignment="Top">
< toolkit:ListPickerItem Content="5"/>
< toolkit:ListPickerItem Content="10"/>
< toolkit:ListPickerItem Content="15"/>
< toolkit:ListPickerItem Content="20"/>
< toolkit:ListPickerItem Content="25"/>
< toolkit:ListPickerItem Content="30"/>
< /toolkit:ListPicker>
The following message comes whenever I try to run this:
System.Windows.Markup.XamlParseException occurred
Message= [Line: 0 Position: 0]
--- Inner Exception ---
The parameter is incorrect.
LineNumber=0
LinePosition=0
StackTrace:
at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
at MS.Internal.XcpImports.MethodEx(DependencyObject obj, String name)
at MS.Internal.XcpImports.FrameworkElement_ApplyTemplate(FrameworkElement frameworkElement)
at System.Windows.FrameworkElement.ApplyTemplateInternal()
at System.Windows.Controls.ScrollContentPresenter.HookupScrollingComponents()
at System.Windows.Controls.ScrollContentPresenter.OnApplyTemplate()
at System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)
at MS.Internal.XcpImports.MeasureNative(IntPtr element, Single inWidth, Single inHeight)
at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
InnerException: System.ArgumentException
Message=The parameter is incorrect.
StackTrace:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh)
at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper doh, DependencyProperty property, Object obj)
at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle, PropertyInvalidationReason reason)
at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Controls.ContentControl.set_Content(Object value)
at System.Windows.Controls.ItemsControl.PrepareContainerForItemOverride(DependencyObject element, Object item)
at System.Windows.Controls.Primitives.Selector.PrepareContainerForItemOverride(DependencyObject element, Object item)
at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
at System.Windows.Controls.ItemsControl.AddVisualChild(Int32 index, DependencyObject container, Boolean needPrepareContainer)
at System.Windows.Controls.ItemsControl.AddContainers()
at System.Windows.Controls.ItemsControl.RecreateVisualChildren(IntPtr unmanagedObj)
at MS.Internal.XcpImports.MethodExNative(IntPtr context, IntPtr element, UInt32 cString, String name, UInt32 cParams, IntPtr pParams, CValue& outval, Int32& typeIndex)
at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
at MS.Internal.XcpImports.MethodEx(DependencyObject obj, String name)
at MS.Internal.XcpImports.FrameworkElement_ApplyTemplate(FrameworkElement frameworkElement)
at System.Windows.FrameworkElement.ApplyTemplateInternal()
at System.Windows.Controls.ScrollContentPresenter.HookupScrollingComponents()
at System.Windows.Controls.ScrollContentPresenter.OnApplyTemplate()
at System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)
at MS.Internal.XcpImports.MeasureNative(IntPtr element, Single inWidth, Single inHeight)
at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
It says that the element is already a child of another one.
But if I remove the last item and keep only five items in the picker, it works fine. What am I getting wrong?

Set the ItemCountThreshold property of the ListPicker to greater that 6 value (by default it lists with five or fewer items). You need something like for example:
<toolkit:ListPicker ItemCountThreshold="10">
<toolkit:ListPickerItem Content="1" />
<toolkit:ListPickerItem Content="2"/>
<toolkit:ListPickerItem Content="3"/>
<toolkit:ListPickerItem Content="4"/>
<toolkit:ListPickerItem Content="5"/>
<toolkit:ListPickerItem Content="6"/>
</toolkit:ListPicker>
ItemCountThreshold:
ItemCountThreshold is a dependency property of type int. It specifies the maximum number of items that will be displayed in Expanded mode. By default, lists with five or fewer items expand in-place while lists with more items switch to a full-screen selection interface. It can also be set to 0 to switch Full mode or a very large number to switch Expanded mode.

I couldn't never make the ListPicker work using ListPickerItem and set ItemCountThreshold="0". Its documentation indicates when the value is set to zero, the full mode should happen automatically. Do not believe it. It does NOT work.
After switched using the code behind with list binding, it finally worked. Why do the hard way (code behind) when it can be simply resolved using the declarative XAML? Hope the ListPickerItem fixed soon.

ItemCountThreshold is now a readonly property in the latest version of the toolkit. There is no easy way to switch to inline expansion with more than 5 items.

Related

Visual Studio 2015 enterprise crashes on startup, uninstall and repair

How can I fix Visual Studio 2015 Enterprise Edition to install and work correctly?
During the installation, it had an issue installing Java SE. It was optional so I didn't think anything of it. I restarted my computer. Now whenever I try to open Visual Studio 2015, reinstall or uninstall, I see the logo briefly then it disappears.
I dug into the event viewer to find a message from Windows Error Reporting that points to a log in the following folder.
C:\users\{me}\AppData\Local\Temp\dd_vs_enterprise_20150720190843
It seems as though it's having difficulty creating the view. I have copied a portion of the log below.
[261C:12FC][2015-07-20T19:08:52]i000: MUX: Detect Completed
[261C:12FC][2015-07-20T19:08:52]i000: MUX: Wait for View to be loaded
[261C:1860][2015-07-20T19:08:52]i000: MUX: Detect Completed, now create view
[261C:1860][2015-07-20T19:08:52]e000: MUX: ERROR: The type initializer for 'System.Windows.Media.FontFamily' threw an exception.
[261C:1860][2015-07-20T19:08:52]e000: MUX: Stack: at System.Windows.Media.Typeface..ctor(FontFamily fontFamily, FontStyle style, FontWeight weight, FontStretch stretch)
at MS.Internal.Text.DynamicPropertyReader.GetTypeface(DependencyObject element)
at MS.Internal.Text.TextProperties.InitCommon(DependencyObject target)
at MS.Internal.Text.TextProperties..ctor(FrameworkElement target, Boolean isTypographyDefaultValue)
at System.Windows.Controls.TextBlock.GetLineProperties()
at System.Windows.Controls.TextBlock.EnsureTextBlockCache()
at System.Windows.Controls.TextBlock.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.StackPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Window.MeasureOverrideHelper(Size constraint)
at System.Windows.Window.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Interop.HwndSource.SetLayoutSize()
at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
at System.Windows.Window.SetRootVisual()
at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
at System.Windows.Window.CreateSourceWindowImpl()
at System.Windows.Window.SafeCreateWindow()
at System.Windows.Window.ShowHelper(Object booleanBox)
at System.Windows.Window.Show()
at Microsoft.Devdiv.Bootstrapper.ManagedUx.RunUI(ViewModelCommonUi viewModel)
at Microsoft.Devdiv.Bootstrapper.ManagedUx.InternalRun()
at Microsoft.Devdiv.Bootstrapper.ManagedUx.Run()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
[261C:1860][2015-07-20T19:08:52]e000: MUX: Exception: Info: InnerException: Info:
[261C:1860][2015-07-20T19:08:52]e000: MUX: ERROR: The type initializer for 'MS.Internal.FontCache.Util' threw an exception.
[261C:1860][2015-07-20T19:08:52]e000: MUX: Stack: at System.Windows.Media.FontFamily.PreCreateDefaultFamilyCollection()
at System.Windows.Media.FontFamily..cctor()
[261C:1860][2015-07-20T19:08:52]i000: MUX: Metrics: ShouldSendData=True
[261C:1860][2015-07-20T19:08:52]i000: MUX: Permission to upload: Yes
[261C:1860][2015-07-20T19:08:52]i000: MUX: Preparing to serialize data.
[261C:1860][2015-07-20T19:08:52]i000: MUX: Data serialized.
[261C:1860][2015-07-20T19:08:52]i000: MUX: Number of SQM File queued: 1
[261C:1860][2015-07-20T19:09:14]i000: MUX: SQM sent: True
[261C:1860][2015-07-20T19:09:14]i000: Setting string variable 'CEIPConsent' to value ''
[261C:1860][2015-07-20T19:09:14]i000: Setting string variable 'SqmOption' to value ''
[261C:1860][2015-07-20T19:09:14]i000: MUX: Metrics: Configuration State
I had a similar issue, and tried the other solutions to no avail. I even repaired the installation but that had no effect. I was able to resolve it by resetting all the user settings.
Navigate to the devenv.exe file; for me it was in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\.
Then open a command prompt there and run:
devenv.exe /ResetSettings
After quite a bit of research, I found two issues that were causing my installation and repair issues.
Font Oddity in the Registry
Open the registry
Go to the font location in the registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontCache
There was a particular font in my case, MT Extra (TTF), which had a long path rather than a filename like the rest of the fonts.
I changed the font name to be just the filename MTEXTRA.TFF
Restarted my computer
PATH longer than 2048 characters
I checked the path to find that it was longer than 2048 characters
This is a known issue (even if difficult to diagnose)
Removed certain entries to bring it down to less than 2048 characters
Restarted
After completing both of these steps, I was able to repair from Programs and Features in the control panel and have a working installation.
I had what seems like the same issue, this is what I did:
Cleared everything out of %temp%, which on my machine is "C:\Users[user name]\AppData\Local\Temp"
Rebooted my machine.
Cleared the rest of the locked files out of %temp% after reboot (this can probably be one step after reboot, but that's the order I went in).
Deleted all the "Roboto" Fonts in my Android SDK folder for the highest version installed. For me, the highest version was android-17:
C:\Users[user name]\AppData\Local\Android\android-sdk\platforms\android-17\data\fonts
Note that "Roboto-Bold.ttf" font was still in use even after reboot, so I didn't delete it. But the problem went away with all the others deleted.
Hope that helps...

Sitecore 7 ContentSearch crawling failure: "Crawler : AddRecursive DoItemAdd failed"

When we try to rebuild our Lucene (ContentSearch) indexes, our CrawlingLog is filled up with these exceptions:
7052 15:08:21 WARN Crawler : AddRecursive DoItemAdd failed - {5A1E50E4-46B9-42D5-B743-1ED10D15D47E}
Exception: System.AggregateException
Message: One or more errors occurred.
Source: mscorlib
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at System.Threading.Tasks.Parallel.PartitionerForEachWorker[TSource,TLocal](Partitioner`1 source, ParallelOptions parallelOptions, Action`1 simpleBody, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body)
at Sitecore.ContentSearch.AbstractDocumentBuilder`1.AddItemFields()
at Sitecore.ContentSearch.LuceneProvider.CrawlerLuceneIndexOperations.GetIndexData(IIndexable indexable, IProviderUpdateContext context)
at Sitecore.ContentSearch.LuceneProvider.CrawlerLuceneIndexOperations.BuildDataToIndex(IProviderUpdateContext context, IIndexable version)
at Sitecore.ContentSearch.LuceneProvider.CrawlerLuceneIndexOperations.Add(IIndexable indexable, IProviderUpdateContext context, ProviderIndexConfiguration indexConfiguration)
at Sitecore.ContentSearch.SitecoreItemCrawler.DoAdd(IProviderUpdateContext context, SitecoreIndexableItem indexable)
at Sitecore.ContentSearch.HierarchicalDataCrawler`1.CrawlItem(Tuple`3 tuple)
Nested Exception
Exception: System.ArgumentOutOfRangeException
Message: Index and length must refer to a location within the string.
Parameter name: length
Source: mscorlib
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at Sitecore.Data.ShortID.Encode(String guid)
at Sitecore.ContentSearch.FieldReaders.MultiListFieldReader.GetFieldValue(IIndexableDataField indexableField)
at Sitecore.ContentSearch.FieldReaders.FieldReaderMap.GetFieldValue(IIndexableDataField field)
at Sitecore.ContentSearch.LuceneProvider.LuceneDocumentBuilder.AddField(IIndexableDataField field)
at System.Threading.Tasks.Parallel.<>c__DisplayClass32`2.<PartitionerForEachWorker>b__30()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass11.<ExecuteSelfReplicating>b__10(Object param0)
This appears to be caused by the ShortID.Encode(string) method expecting the GUID in the string parameter to have brackets (" { " and " } ") around it. Some of our multilist field relationships were associated programmatically using Guid.ToString(), which does not include the brackets. Unfortunately, these values cause the ShortID.Encode() method to choke.
First things first: find all the places you call MultiListField.Add(string) and change Guid.ToString() to Guid.ToString("B"). This will resolve the issue for all new relationships.
Create a custom FieldReader class to replace the standard MultiListFieldReader (we called ours CustomMultiListFieldReader).
Set your custom class to inherit from Sitecore.ContentSearch.FieldReaders.FieldReader.
Decompile the Sitecore.ContentSearch.FieldReaders.MultiListFieldReader.GetFieldValue(IIndexableDataField) method into your custom class.
Before the if (ID.IsID(id)) line, add the following code:
if (!str.StartsWith("{") && !str.EndsWith("}"))
id = String.Format("{{{0}}}", str);
In your index configuration (we added ours to the default, Sitecore.ContentSearch.DefaultIndexConfiguration.config) change the fieldReaderType for the MultiList fields to your custom type. (This can be found in your config at sitecore/contentSearch/configuration/defaultIndexConfiguration/fieldReaders/mapFieldByTypeName/fieldReader.)
Full disclosure: I don't love this approach because if the default implementation of the MultiListFieldReader ever changed, we'd be without those changes. But this allows the items to be included in the index without reformatting all of the GUIDs in every multilist field.

AssertionFailure - collection was processed twice by flush() causes Orchard CMS site to crash

I am running Orchard CMS 1.7.2. I created a custom module called BYUtv.Shapes as a place to store reusable shape methods. I have a class called RelatedToShow : IDependency in this module. The method of interest in this class is called RelatedEpisodes. The purpose of this shape method is to retrieve Episodes data, via a query created in the admin ui, for Episodes related to a specific Show. In the manager the Episode content type definition has a Content Picker Field that allows a content manager to pick a Show that the Episode is part of or related to. The query that I created is working correctly and returning the correct data. With that explanation here is my shape method.
[Shape]
public IHtmlString RelatedEpisodes(dynamic Shape, dynamic Display, int? PageSize, string PagerSuffix = "")
{
// Retrieves the QueryPart by name for the query called Related Episodes Year.
// Related Episodes Year retrieves Episodes that are related to a specific show with an optional year filter.
QueryPart episodesQuery = GetQueryPartByName("Related Episodes Year");
dynamic pager = CreatePager(Shape, _projectionManager.GetCount(episodesQuery.Id), PageSize, PagerSuffix);
int startIndex = pager.Pager.GetStartIndex();
int pageSize = pager.Pager.PageSize;
IEnumerable<ContentItem> contentItems = new List<ContentItem>();
if(episodesQuery != null)
{
contentItems = _projectionManager.GetContentItems(episodesQuery.Id, startIndex, pageSize);
}
// Retrieves the QueryPart by name for the query called Related Episodes.
// Related Episodes retrieves Episodes that are related to a specific show.
QueryPart newestEpisodeQuery = GetQueryPartByName("Related Episodes");
ContentItem newestEpisode = null;
if (newestEpisodeQuery != null)
{
newestEpisode = _projectionManager.GetContentItems(newestEpisodeQuery.Id, 0, 1).FirstOrDefault();
}
// Retrieves a list of distinct years that the episodes premiered in.
List<string> years = _projectionManager.GetContentItems(newestEpisodeQuery.Id).Select(y => (string)((dynamic)y).TimeSpanPart.StartDateTime.Year.ToString()).Distinct().ToList();
return Display.RelatedEpisodesView(ContentItems: contentItems, Pager: pager, NewestEpisode: newestEpisode, YearFilter: GetYearFilter(), Years: years);
}
In all my testing this always works locally. It also works in production but seemingly randomly crashes the page it is used on in production. If I comment the code that runs this shape method in production than the rest of the page runs as desired. The only difference that I am aware of between production and local is possibly the HostCompontents.config file and the traffic volume. In production I turn off several properties because I understand it will help performance.
Here are the logs from the production server.
Exception information:
Exception type: AssertionFailure
Exception message: collection was processed twice by flush()
at NHibernate.Engine.Collections.PrepareCollectionForUpdate(IPersistentCollection collection, CollectionEntry entry, EntityMode entityMode, ISessionFactoryImplementor factory) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Engine\Collections.cs:line 164
at NHibernate.Event.Default.AbstractFlushingEventListener.FlushCollections(IEventSource session) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Event\Default\AbstractFlushingEventListener.cs:line 92
at NHibernate.Event.Default.AbstractFlushingEventListener.FlushEverythingToExecutions(FlushEvent event) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Event\Default\AbstractFlushingEventListener.cs:line 61
at NHibernate.Event.Default.DefaultAutoFlushEventListener.OnAutoFlush(AutoFlushEvent event) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Event\Default\DefaultAutoFlushEventListener.cs:line 32
at NHibernate.Impl.SessionImpl.AutoFlushIfRequired(ISet`1 querySpaces) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\SessionImpl.cs:line 1180
at NHibernate.Impl.SessionImpl.List(String query, QueryParameters queryParameters, IList results) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\SessionImpl.cs:line 616
at NHibernate.Impl.SessionImpl.List(String query, QueryParameters parameters) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\SessionImpl.cs:line 593
at NHibernate.Impl.QueryImpl.List() in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\QueryImpl.cs:line 64
at NHibernate.Impl.AbstractQueryImpl.UniqueResult() in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\AbstractQueryImpl.cs:line 960
at Orchard.ContentManagement.DefaultHqlQuery.Count() in c:\Source\BYUB\byuradio2\orchard\src\Orchard\ContentManagement\DefaultHqlQuery.cs:line 212
at Orchard.Projections.Services.ProjectionManager.<GetCount>b__14(IHqlQuery contentQuery)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.Sum(IEnumerable`1 source)
at Orchard.Projections.Services.ProjectionManager.GetCount(Int32 queryId)
at BYUtv.Shapes.Drivers.RelatedToShow.RelatedEpisodes(Object Shape, Object Display, Nullable`1 PageSize, String PagerSuffix)
and
Stack trace: at NHibernate.Engine.Collections.PrepareCollectionForUpdate(IPersistentCollection collection, CollectionEntry entry, EntityMode entityMode, ISessionFactoryImplementor factory) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Engine\Collections.cs:line 164
at NHibernate.Event.Default.AbstractFlushingEventListener.FlushCollections(IEventSource session) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Event\Default\AbstractFlushingEventListener.cs:line 92
at NHibernate.Event.Default.AbstractFlushingEventListener.FlushEverythingToExecutions(FlushEvent event) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Event\Default\AbstractFlushingEventListener.cs:line 61
at NHibernate.Event.Default.DefaultAutoFlushEventListener.OnAutoFlush(AutoFlushEvent event) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Event\Default\DefaultAutoFlushEventListener.cs:line 32
at NHibernate.Impl.SessionImpl.AutoFlushIfRequired(ISet`1 querySpaces) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\SessionImpl.cs:line 1180
at NHibernate.Impl.SessionImpl.List(String query, QueryParameters queryParameters, IList results) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\SessionImpl.cs:line 616
at NHibernate.Impl.SessionImpl.List(String query, QueryParameters parameters) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\SessionImpl.cs:line 593
at NHibernate.Impl.QueryImpl.List() in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\QueryImpl.cs:line 64
at NHibernate.Impl.AbstractQueryImpl.UniqueResult() in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Impl\AbstractQueryImpl.cs:line 960
at Orchard.ContentManagement.DefaultHqlQuery.Count() in c:\Source\BYUB\byuradio2\orchard\src\Orchard\ContentManagement\DefaultHqlQuery.cs:line 212
at Orchard.Projections.Services.ProjectionManager.<GetCount>b__14(IHqlQuery contentQuery)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.Sum(IEnumerable`1 source)
at Orchard.Projections.Services.ProjectionManager.GetCount(Int32 queryId)
at BYUtv.Shapes.Drivers.RelatedToShow.RelatedEpisodes(Object Shape, Object Display, Nullable`1 PageSize, String PagerSuffix)
The error seems to always relate to collection was processed twice by flush(). I have even tried creating the query directly in the code with similar results.
Another question that was posted is Orchard cms 1.7.2 GenericADOException. Some of the side effects expressed there are similar to what I am having.
Are there any glaring issues that you can see in this code that are causing these errors?
Have you run into this or similar issues?
Any thoughts on how to resolve this problem?

What does this usually mean, Error HRESULT E_FAIL has been returned from a call to a COM component.?

I have a particular view with a DataGrid (silverlight 4). But i have a project where resources have been merged with another project (for backward support). Now, after this merge, i am getting this error whenever i try to add a new row oject to my ObservableCollection.... my theory is that it is something wrong with the xaml (which i can touch!) or, hopefully, the merged resources (styles & brushes).
MS.Internal.WrappedException was unhandled by user code
Message=Error HRESULT E_FAIL has been returned from a call to a COM component.
StackTrace:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.DataGrid.InsertDisplayedElement(Int32 slot, UIElement element, Boolean wasNewlyAdded, Boolean updateSlotInformation)
at System.Windows.Controls.DataGrid.OnAddedElement_Phase1(Int32 slot, UIElement element)
at System.Windows.Controls.DataGrid.OnInsertedElement_Phase1(Int32 slot, UIElement element, Boolean isCollapsed, Boolean isRow)
at System.Windows.Controls.DataGrid.InsertElement(Int32 slot, UIElement element, Boolean updateVerticalScrollBarOnly, Boolean isCollapsed, Boolean isRow)
at System.Windows.Controls.DataGrid.InsertElementAt(Int32 slot, Int32 rowIndex, Object item, DataGridRowGroupInfo groupInfo, Boolean isCollapsed)
at System.Windows.Controls.DataGrid.InsertRowAt(Int32 rowIndex)
at System.Windows.Controls.DataGridDataConnection.NotifyingDataSource_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Windows.Data.PagedCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Data.PagedCollectionView.ProcessAddEvent(Object addedItem, Int32 addIndex)
at System.Windows.Data.PagedCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Data.PagedCollectionView.<.ctor>b__0(Object sender, NotifyCollectionChangedEventArgs args)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
InnerException:
Message=Error HRESULT E_FAIL has been returned from a call to a COM component.
StackTrace:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
InnerException:
This usually means that there is a problem with your XAML that couldn't be validated at design time but would manifest in runtime. Given your scenario I'm guessing the row you're adding may cause one of the Datagrid column templates to error in this manner.
This usually is due to a reference to a style or an event handler that does not exist or is not within the context of the XAML. In my experience this is a common occurence in Custom Control development.
See my answer to a similar question here.
HTH.

Exception "Element is already the child of another element." when navigating to the startup view

I'm using Region Navigation integrated with the Silverlight Frame Navigation as follows: I have my frame, to which I attached a region, and set the ContentLoader to the FrameContentLoader which I got from Karl Shiflett's example:
<navigation:Frame
x:Name="ContentFrame"
Style="{StaticResource ContentFrameStyle}"
Source="/Home"
Navigated="ContentFrame_Navigated"
NavigationFailed="ContentFrame_NavigationFailed"
prism:RegionManager.RegionName="MainContentRegion">
<navigation:Frame.ContentLoader>
<prism_Regions:FrameContentLoader RegionName="MainContentRegion"/>
</navigation:Frame.ContentLoader>
<navigation:Frame.UriMapper>
<uriMapper:UriMapper>
<uriMapper:UriMapping Uri="" MappedUri="/MyProject.Views.Home" />
<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/MyProject.Views.{pageName}" />
</uriMapper:UriMapper>
</navigation:Frame.UriMapper>
</navigation:Frame>
I get the following exception: "Element is already the child of another element.", here's the stack trace:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
at System.Windows.Controls.ContentControl.set_Content(Object value)
at System.Windows.Navigation.NavigationService.CompleteNavigation(DependencyObject content)
at System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback(IAsyncResult result)
this happens whenever I try to navigate to the Home view, whereas all the other navigation request complete successfully! To make sure that the problem isn't with the view itself, I tried replacing Home with About which is an existing view (making it the startup view), but the problem still exists! Now, I can navigate to Home but not About.
what could cause such a problem?
PS: the problem persists even after I removed the assignement of the Source property for the Frame, and the default UriMapper (the first one). With this, I have the error with the first view I visit, the others work fine.
I finally stumbled upon the "real cause" of this problem!
I found the following lines in my App.xaml
protected virtual void InitializeRootVisual()
{
BusyIndicator busyIndicator = new BusyIndicator();
busyIndicator.Content = new Shell();
busyIndicator.HorizontalContentAlignment = HorizontalAlignment.Stretch;
busyIndicator.VerticalContentAlignment = VerticalAlignment.Stretch;
this.RootVisual = busyIndicator;
}
I'm not really sure as to what really happened here that caused the issue (maybe someone can enlighten me on that), but removing this solved the problem.
I hope this could help somebody (maybe a "future me") someday :)