Silverlight Application Error 0x17F8 on ComboBox_DropDownOpened - silverlight

I have several similar comboboxes with custom templates that display one custom control on the dropdown. Suddenly one of those controls have broken and they give me the following error when I open the combobox.
Message: Unhandled Error in Silverlight 2 Application Error 0x17F8. Debugging resource strings are unavailable. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.50401.0&File=mscorrc.dll&Key=0x17F8 at <INSERT_NAMESPACE>.ComboBox_DropDownOpened(Object sender, EventArgs e)
at System.Windows.Controls.ComboBox.OnDropDownOpened(EventArgs e)
at System.Windows.Controls.ComboBox.OnIsDropDownOpenChanged(Boolean isDropDownOpen)
at System.Windows.Controls.ComboBox.OnIsDropDownOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, 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.DependencyObject.SetValue(DependencyProperty property, Boolean b)
at System.Windows.Controls.ComboBox.ElementDropDownToggle_Click(Object sender, RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Primitives.ToggleButton.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
Line: 1
Char: 1
Code: 0
As you can see this only happens in deployed release versions and on the machines with no development environments. The same release version (and debug version) is working on my development machine.
I wrapped everything on the DropDownOpened event handler inside a try-catch-block to get more information but the catch doesn't fire at all.
I tried to Google the error but so far haven't found anything that would be helpful. Any advice how to start solving this? Could this be related to Silverlight runtime version or something that should be installed on the release machines as well?

I managed to solve the issue. I installed Developer Runtime to the machine for the hope that it would reveal better error message from the Exception. And it did! The issue was in the code of the control that was being displayed in the combobox dropdown. I fixed the bug and it's now working fine. Apparently even the strangest error message can mean the simplest thing :)
I wonder if there is a drawback on having the developer runtime instead of the standard runtime?

Related

How to resolve InvalidOperationException while adding a WPF UI Element to the Winform Grid Control Panel?

We have a CRM Add-in for Microsoft Outlook, which displays a custom task pane which has a WinForm control inside a WPF form/control as one of its functionalities. But, since after Version 1812 and the latest update to Office 365 pro plus installations, in some of the client machines we have been facing the following error/exceptions and form doesn't show or load:
System.InvalidOperationException: Hosted HWND must be a child window
of the specified parent. at
System.Windows.Interop.HwndHost.BuildWindow(HandleRef hwndParent)
at System.Windows.Interop.HwndHost.BuildOrReparentWindow() at
System.Windows.Interop.HwndHost.OnSourceChanged(Object sender,
SourceChangedEventArgs e) at
System.Windows.SourceChangedEventArgs.InvokeEventHandler(Delegate
genericHandler, Object genericTarget) at
System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object
target) at
System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target,
RoutedEventArgs routedEventArgs) at
System.Windows.EventRoute.InvokeHandlersImpl(Object source,
RoutedEventArgs args, Boolean reRaised) at
System.Windows.UIElement.RaiseEventImpl(DependencyObject sender,
RoutedEventArgs args) at
System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) at
System.Windows.PresentationSource.UpdateSourceOfElement(DependencyObject
doTarget, DependencyObject doAncestor, DependencyObject doOldParent)
at
System.Windows.PresentationSource.OnVisualAncestorChanged(DependencyObject
uie, AncestorChangedEventArgs e) at
System.Windows.UIElement.OnVisualAncestorChanged(Object sender,
AncestorChangedEventArgs e) at
System.Windows.Media.Visual.ProcessAncestorChangedNotificationRecursive(DependencyObject
e, AncestorChangedEventArgs args) at
System.Windows.Media.Visual.FireOnVisualParentChanged(DependencyObject
oldParent) at System.Windows.Media.Visual.AddVisualChild(Visual
child) at System.Windows.Media.VisualCollection.ConnectChild(Int32
index, Visual value) at
System.Windows.Media.VisualCollection.Add(Visual visual) at
System.Windows.Controls.UIElementCollection.AddInternal(UIElement
element) at System.Windows.Controls.UIElementCollection.Add(UIElement
element)
Basically, the code fails while embedding and displaying the WPF form. The exact code snippet causing the issue is as follows:
public void DisplayForm(System.Windows.Forms.Control form)
{
// Adapt WinForm Form Control to WPF
System.Windows.Forms.Integration.WindowsFormsHost wfh = new System.Windows.Forms.Integration.WindowsFormsHost();
wfh.Child = form;
wfh.Margin = new Thickness(0);
// Display WPF Form
DisplayForm(wfh);
}
// Embed a WPF Control
public void DisplayForm(UIElement form)
{
HostPanel.Children.Clear();
//***Below line throws an exception***
HostPanel.Children.Add(form);
}
In the above code,
HostPanel: System.Windows.Controls.Grid
Children: UIElementCollection Panel
Also, the HostPanel or the grid has been used/placed in the XAML like below :
<Grid>
<!-- Form Panel -->
<Grid Name="HostPanel" Margin="0,50,0,0">
</Grid>
And, in the XAML code partial class:
We are assigning the Winform control as a child of the WPF.
Then, we are trying to add the WPF form/UIElement in the UIElementCollection Panel of the grid control.
It is really difficult to narrow down to the exact root cause of the issue when everything was working as expected and just after pushing the updates to the Microsoft Office, the errors/exceptions are being seen.
Any help or pointers towards resolving the issue will be greatly appreciated.
Thanks!
**
Update
**
This issue seems to be due to Microsoft introduced Office support for High DPI
And the issue could be fixed inside Outlook by selecting "Optimize for compatibility" in Display Settings on the bottom status bar or in User Interface options under General Outlook options:
Image for the setting/configuration
However, is there a way to make the above-mentioned code DPI aware and to get the form controls rendered without any issue?
Also, from this MSDN Article, I learn that it might not be possible as child parented to Office window cannot respond to DPI scaling. But, any further inputs on the same would be highly appreciated.
Thanks.

A NullReferenceException exception in System.Windows.Forms.DataGridView

I have a .NET 4.0 WinForms application. A Form of the application contains a Grid – an System.Windows.Forms.DataGridView object
Suddenly I have got a (non-reproducible!) NullReferenceException in it. The call stack was the following:
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.DataGridView.UnwireEditingControlEvents()
at System.Windows.Forms.DataGridView.EndEdit(DataGridViewDataErrorContexts context, DataGridViewValidateCellInternal validateCell, Boolean fireCellLeave, Boolean fireCellEnter, Boolean fireRowLeave, Boolean fireRowEnter, Boolean fireLeave, Boolean keepFocus, Boolean resetCurrentCell, Boolean resetAnchorCell)
at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick)
at System.Windows.Forms.DataGridView.set_CurrentCell(DataGridViewCell value)
at System.Windows.Forms.DataGridView.OnClearingRows()
at System.Windows.Forms.DataGridViewRowCollection.ClearInternal(Boolean recreateNewRow)
at System.Windows.Forms.DataGridView.RefreshRows(Boolean scrollIntoView)
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e)
at System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.InnerList_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.FireListChanged(ListChangedType type, Int32 index)
at System.ComponentModel.BindingList`1.ClearItems()
at System.Collections.ObjectModel.Collection`1.Clear()
at <My Code>;
The calls method Clear of a BindingList-derived list. The BindingList-derived list is, in turn, used in a BindingSource object. The BindingSource object is a datasource of the DataGridView.
I cannot understand – why this happens? And why it happens only sometimes? (to the moment I have seen the problem only once).
And how can this be avoided?
Ran into this myself just now. In my case, I noticed it only happens if the grid has more than about 10 rows or so and you immediately try to go to the last row. My workaround was, after setting the BindingSource, to manually set the current cell to a cell within the first row:
grdConditions.DataSource = myDataSource;
if (grdConditions.Rows.Count > 0)
grdConditions.CurrentCell = grdConditions[0, grdConditions.RowCount - 1];
Seemed to fix the issue for me.

Error in Upgrading Silverlight

I've inherited a fairly big project that needed upgrading from Silverlight 2 to Silverlight 4. I recently ran into an error trying to test the project.
Microsoft JScript runtime error: Unhandled Error in Silverlight Application Set property 'System.Windows.FrameworkElement.Style' threw an exception. [Line: 257 Position: 27] at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at ESM.Visualization.MainPage.InitializeComponent()
at ESM.Visualization.MainPage..ctor()
at ESM.Visualization.App.Application_Startup(Object sender, StartupEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
I think there might be some files that went missing between Silverlight 2 and 4, but I'm not sure where to start looking for changes to fix. Any help would be appreciated.

Causes of intermitant Arg_ArgumentException on in Production deployment?

We have just recently deployed a Trusted, In-Browser, Silverlight 5 application to our Production webserver. We are getting fairly frequent ArgumentExceptions captured by the App.xaml.cs UnhandledException handler. So far we have been unable to determine the source of the exception.
We are not seeing the exception when running under the debugger (I have that explicitly enabled the exception for capture under Debug->Exceptions....). Some users see this error very frequently, while others never see the error. It doesn't seem to be a fatal error as the users can just click the OK button from the ErrorWindow that we display and everything functions normally.
To stop annoying the users, I have added a handler for ArgumentException types and just mark it as handled and continue on. However, I am still logging the errors and would really like to determine the actual source so that I can fix the problem. Just ignoring the exception doesn't seem like a long term solution.
The Stack trace is below and is the same for all ArgumentExceptions.
Any ideas on how I can troubleshoot better and determine the cause of this exception?
Thanks,
Tim
Unhandled Exception: [Arg_ArgumentException]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.0.10411.00&File=mscorlib.dll&Key=Arg_ArgumentException :
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, Double d)
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.RefreshExpression(DependencyProperty dp)
at System.Windows.Data.BindingExpression.SendDataToTarget()
at System.Windows.Data.BindingExpression.SourceAcquired()
at System.Windows.Data.BindingExpression.PerformTargetLoaded()
at System.Windows.Data.BindingExpression.TargetLoaded(Object o, RoutedEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex

Silverlight Cache Control: Using revision number in url for XAP causes HyperLink to crash SL App!

To make sure all our customers receive the latest Silverlight App, we are placing the new revision number on the url for XAP file as follows:
<param name="source" value="/ClientBin/ShoeboxViewer.xap?v=5" />
Problem is when we do this, all HyperLink controls (in the Silverlight App) that use relative URLs, throw an internal error when clicked. Here's the stack trace:
Unhandled Error in Silverlight 2 Application Specified argument was out of the range of valid values. Parameter name: baseUri
at System.Uri..ctor(Uri baseUri, Uri relativeUri)
at System.Windows.Controls.HyperlinkButton.GetAbsoluteUri()
at System.Windows.Controls.HyperlinkButton.Navigate()
at System.Windows.Controls.HyperlinkButton.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
If I remove the querystring, it works fine.
Can anyone help?
Cheers,
Ash.
Jacob is right - you might also want to look at this solution to fixup relative URLs.
The problem is actually that HyperlinkButtons can't use relative urls. I ran into this just the other day. It's a hack, but I got it to work by adding a click handler to the HyperlinkButton and then calling HtmlPage.Navigate, passing in a uri marked as relative

Resources