Visual Studio 2015 enterprise crashes on startup, uninstall and repair - crash

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...

Related

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.

What things should I consider when I get an intermittent exception in Visual Basic .net (debugging in Visual Studio Express 2010)?

I'm testing my Visual Basic .net application by running it in Visual Studio express.
Sometimes it runs OK, but other times I get an exception (details below, if useful). I'm not sure why I get the exception as the particular part of the application that I am testing re-uses code that works OK for other features.
What should I check, what would give me a hint as to the root cause.
Things I tried so far are:
Rewriting some of the code to be more robust. The outcome of this was that this approach was getting out of control - I was correcting everything. I made changes such asing alternative libraries (e.g. replacing CInt with convertTo etc). Some lazy declarations, but it occurred to me that there was no problem with these with the code before my changes. And every change I seemed to solve uncovered yet another problem, another different exception
So I thought something must be fundamentally wrong with my installation, and a search found discussion group posts from people experiencing something similar. The suggested remedy would be to re-install the .net framework. So I did that and the problems still occured.
Any thoughts on approach to get to the root of the problem? I'm not asking for a solution but some fresh ideas would be very welcome.
Update:
I've added in the following code to get more detail (+1 thanks #Meta-Knight)
Dim exceptionMessage As String = ex.Message
Console.WriteLine("Message: \n" & exceptionMessage)
Dim exceptionTargetSite As String = ex.TargetSite.ToString
Console.WriteLine("Inner: \n" & ex.TargetSite.ToString)
Dim exceptionSource As String = ex.Source
Console.WriteLine("Source\n:" & exceptionSource)
' put the stack trace into a variable
' (this helps debugging - put a break point after this is assigned
' to see the contents)
Dim stackTrace As String = ex.StackTrace.ToString()
Console.WriteLine("Stack trace\n:" & stackTrace)
More details about exception
Error - Exception Message
"Arithmetic operation resulted in an overflow."
Exception Target Site:
"Int32 ToInteger(System.String)"
Exception Source:
"Microsoft.VisualBasic"
at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value) at MyCo_3rd-Party-Industrial-Printing-System.Customer_EanUpc_serialNumberGeneratorAssembly.btnPrint_Click(Object sender, EventArgs e) in C:\labelprint\MyCo 3rd-Party-Industrial-Printing-System v2\MyCo 3rd-Party-Industrial-Printing-System\PrintForms\Customer_EanUpc_serialNumberGeneratorAssembly.vb:line 271 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.PerformClick() at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData) at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData) at System.Windows.Forms.Control.PreProcessMessage(Message& msg) at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg) at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg) at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.RunDialog(Form form) at System.Windows.Forms.Form.ShowDialog(IWin32Window owner) at System.Windows.Forms.Form.ShowDialog() at MyCo_3rd-Party-Industrial-Printing-System.utlForm.openNewModalForm(String form) in C:\labelprint\MyCo 3rd-Party-Industrial-Printing-System v2\MyCo 3rd-Party-Industrial-Printing-System\Utilities\utlForm.vb:line 128
Update 2:
The code around line 272 was:
For i As Integer = 1 To CInt(numQuantity)
If generationMethods() Then
The code around line 272 is now (I've adjusted it):
Dim numQuantityAsStr As String = numQuantity.Text
Dim numQuantityAsInt As Integer = Convert.ToInt32(numQuantityAsStr)
For i As Integer = 1 To numQuantityAsInt
If generationMethods() Then
numQuantity is a String variable for a field in the Windows form I am using and this has a value put in it by the user, the field is used to specify the quantity of something so this variable is converted to a integer so that it can be used in a for loop. The test value I am using is always entering 1 in this field, and sometimes this causes the exception.
My alteration uses what I think is a more modern type conversion Convert.ToInt32 rather than CInt I've also introduced intermediate steps to help debug.
The exception now does not occur here but I did try this the other week and another separate exception popped up (if I remember) from somewhere else so we'll see if this fixes it. Any thoughts as to why using a different conversion utility would solve the problem?
Update 3:
An Exception now occurs elsewhere:
(But why?! This one is thrown from library code!)
The following code caused it:
Dim dateNowAsStr As String = DateTime.Now.Date.ToString
Exception Message:
"Value to add was out of range. Parameter name: value"
Exception target site:
"System.DateTime Add(Double, Int32)"
Exception source:
"mscorlib"
" at System.DateTime.Add(Double value, Int32 scale) at System.TimeZoneInfo.TransitionTimeToDateTime(Int32 year, TransitionTime transitionTime) at System.TimeZoneInfo.GetDaylightTime(Int32 year, AdjustmentRule rule) at System.TimeZoneInfo.GetIsDaylightSavingsFromUtc(DateTime time, Int32 Year, TimeSpan utc, AdjustmentRule rule, Boolean& isAmbiguousLocalDst) at System.TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc(DateTime time, Boolean& isAmbiguousLocalDst) at System.DateTime.get_Now() at GenerationLibrary.GenerationUtilities.callserialNumberGenerator(String serialNumberGeneratorSnFile, String serialNumberGeneratorRange, DefaultSettingsHandler settings) in C:\labelprint\MyCo 3rd-Party-Industrial-Printing-System v2\GenerationLibrary\GenerationUtilities.vb:line 28 at GenerationLibrary.MyCoSnGeneration.constructMyCoSn(DataRow& oDataRow, DefaultSettingsHandler& settings) in C:\labelprint\MyCo 3rd-Party-Industrial-Printing-System v2\GenerationLibrary\MyCoSnGeneration.vb:line 18 at MyCo_3rd-Party-Industrial-Printing-System.Customer_EanUpc_serialNumberGeneratorAssembly.generationMethods() in C:\labelprint\MyCo 3rd-Party-Industrial-Printing-System v2\MyCo 3rd-Party-Industrial-Printing-System\PrintForms\Customer_EanUpc_serialNumberGeneratorAssembly.vb:line 40 at MyCo_3rd-Party-Industrial-Printing-System.Customer_EanUpc_serialNumberGeneratorAssembly.btnPrint_Click(Object sender, EventArgs e) in C:\labelprint\MyCo 3rd-Party-Industrial-Printing-System v2\MyCo 3rd-Party-Industrial-Printing-System\PrintForms\Customer_EanUpc_serialNumberGeneratorAssembly.vb:line 275 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.PerformClick() at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData) at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData) at System.Windows.Forms.Control.PreProcessMessage(Message& msg) at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg) at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg) at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.RunDialog(Form form) at System.Windows.Forms.Form.ShowDialog(IWin32Window owner) at System.Windows.Forms.Form.ShowDialog() at MyCo_3rd-Party-Industrial-Printing-System.utlForm.openNewModalForm(String form) in C:\labelprint\MyCo 3rd-Party-Industrial-Printing-System v2\MyCo 3rd-Party-Industrial-Printing-System\Utilities\utlForm.vb:line 128"
Update 4
BUT
Dim dateNowAsStr As String = CStr(DateTime.Now)
does not cause the exception
Before rewriting or reinstalling anything, you should try to identify the source and the reason for the error.
The first thing to do is to analyse the error message and stack trace. If you include debugging files (.pdb) with your application's files, you will get more detailed information such as the line number which can be helpful.
If that doesn't give enough information about the circumstances of the error, then you can add some logging to your app. By logging what the user does in your app it might help reproduce the problem.
Finally you can always get help by searching on google or asking on StackOverflow, but make sure to include the actual error message, not just the stack trace... You should also post the code where the error happens.
Edit:
So the actual error is: "Arithmetic operation resulted in an overflow."
Googling this would have helped: you would have found out that such an error happens when you're trying to convert a number which is out of bounds for an integer. If you expect to have some very large numbers you can try converting to Long instead.
I think you can start by looking at what is at line 271 of the Customer_EanUpc_serialNumberGeneratorAssembly.vb source code file.
Which is located: C:\labelprint\MyCo 3rd-Party-Industrial-Printing-System v2\MyCo 3rd-Party-Industrial-Printing-System\PrintForms\ directory.
It looks like the problem is related to a conversion between string to integer where maybe it failed because the string cannot be converted to integer... maybe it has alphanumeric characters...
"Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)"
Did you already check that?
Why you get the error some times and not always could be because (and I'm guessing here) the code in serialNumberGeneratorAssembly sometimes generates numeric only values (that can be correctly converted to integer) and some other times generates alphanumeric serial numbers (that throw the convertion exception).
UPDATE: the code that generates the Serial Numbers is generating numbers bigger than an Integer value. Try converting to Long instead of Integer... or have a look at System.Numerics.BigInteger in case those numbers are too big.
That explains the: "Arithmetic operation resulted in an overflow." exception message.

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.

ListPicker crash

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.

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 :)