MediaFailed event fired twice from time to time, my xaml is as below:
<controls:MediaUriElement Name="videoMedia" HorizontalAlignment="Center" Margin="20 20 20 5" VerticalAlignment="Center"
DeeperColor="False" VideoRenderer="EnhancedVideoRenderer" UnloadedBehavior="Stop"
MediaOpened="videoMedia_MediaOpened" MediaFailed="videoMedia_MediaFailed"
/>
the information for first MediaFailedEventArgs.Exception is as below:
Message "The download of the specified resource has failed"
Source "DirectShowLib-2005"
StackTrace:
" at DirectShowLib.DsError.ThrowExceptionForHR(Int32 hr)\r\n at WPFMediaKit.DirectShow.MediaPlayers.MediaUriPlayer.oldOpenSource()"
Second exception is as below:
Message "Unspecified error"
Source "DirectShowLib-2005"
StackTrace:
" at DirectShowLib.DsError.ThrowExceptionForHR(Int32 hr)\r\n at WPFMediaKit.DirectShow.MediaPlayers.MediaUriPlayer.OpenSource()"
Note: because my application is target for .NET 4.0, I change the source code and rebuild in my local machine, the source code change is:
change D3DRenderer.cs from
D3DImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, backBuffer, true);
to
D3DImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, backBuffer);
Related
I have decided to learn ReactiveUI after seeing what can be done with it, but my enthusiasm has been broken at the first attempt to run a simple project. I have recreated the example from this article, using reactiveui-winforms.Net40 version 6.5.0 from NuGet. Everything compiles ok, but i get an exception during runtime at the following line
var OKCmdObs = this.WhenAny(vm => vm.EnteredText,
s => !string.IsNullOrWhiteSpace(s.Value));
System.InvalidOperationException occurred
HResult=-2146233079
Message=The current thread has no Dispatcher associated with it.
Source=System.Reactive.Windows.Threading
StackTrace:
at System.Reactive.Concurrency.DispatcherScheduler.get_Current()
at ReactiveUI.PlatformRegistrations.<>c.<Register>b__0_7() in C:\workspace\git-perso\ReactiveUI\ReactiveUI\Platform\Registrations.cs:line 75
InnerException:
Does anyone have any idea of what's happening ?
The mentioned article does not have the compiled project available for download, and i didn't find any complete "Hello-World" project for reactiveui-winforms.
My test project can be downloaded here.
In Visual Studio, if i Continue(F5), another exception occures :
System.NullReferenceException occurred
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=ReactiveUI
StackTrace:
at ReactiveUI.IROObservableForProperty.<>c__DisplayClass1_0.<GetNotificationForProperty>b__6(IReactivePropertyChangedEventArgs`1 x) in C:\workspace\git-perso\ReactiveUI\ReactiveUI\IROObservableForProperty.cs:line 44
InnerException:
If i continue to hit F5 i get :
System.Exception was unhandled by user code
HResult=-2146233088
Message=An OnError occurred on an object (usually ObservableAsPropertyHelper) that would break a binding or command. To prevent this, Subscribe to the ThrownExceptions property of your objects
Source=ReactiveUI
This exception is caused because RxUI always tries to initialize for WPF, even though (because you're also using the winforms package) it'll override this setting with a Winforms-based scheduler right after.
It should be harmless though, as it's catched and ignored. You're probably hitting it within VS ?
I am adding panorama items to panorama controls dynamically, they are adding successfully without any issues
but when i try to add the listbox to panorama item its giving error. I am not able to see the exception also, application automatically closing and I am seeing emulator home screen after that.
Following is my code which I've written to create panorama item and list box
lstAnniversaries = new ListBox()
lstAnniversaries.Width = 420;
lstAnniversaries.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
lstAnniversaries.Foreground = new SolidColorBrush(FacebookQueries.GetColorFromHexString("#000000"));
lstAnniversaries.Background = new SolidColorBrush(FacebookQueries.GetColorFromHexString("#ffffff"));
lstAnniversaries.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(lstUpcoming_Tap);
lstAnniversaries.ItemTemplate = (DataTemplate)XamlReader.Load(#"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Grid Height=""100"" Margin=""0,0,0,0"">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=""90"" />
<ColumnDefinition Width=""210"" />
<ColumnDefinition Width=""*"" />
</Grid.ColumnDefinitions>
<Image Source=""{Binding ImageSource}"" Height=""90"" Width=""90"" Margin=""0,0,11,0"" />
<StackPanel Grid.Column=""1"" Margin=""0,10,0,0"">
<TextBlock Text=""{Binding NameSource}"" Style=""{StaticResource ProfileNameStyleForTextBlock}"" />
<StackPanel Orientation=""Horizontal"" Margin=""0,-2,0,0"">
<TextBlock Text=""{Binding EventName}"" Foreground=""#000000"" Style=""{StaticResource EventNameStyleForTextBlock}"" />
<TextBlock Text=""{Binding EventDate}"" Foreground=""{Binding EventColor}"" Style=""{StaticResource EventDateStyleForTextBlock}"" />
</StackPanel>
</StackPanel>
<Button VerticalAlignment=""Center"" Height=""Auto"" Name=""btnAnniversary"" Width=""75"" Margin=""5,0,0,0"" HorizontalAlignment=""Left"" Visibility=""{Binding EllipseStatus}"" Tag=""{Binding BindsDirectlyToSource=True}"" Click=""btnAnniversary_Click"" Canvas.ZIndex=""1"" Grid.Column=""2"">
<Image Source=""/GiftGiv;component/Assets/bubble.png"" />
</Button>
</Grid>
</DataTemplate>");
pan_anniversaries = new PanoramaItem();
pan_anniversaries.HeaderTemplate = (DataTemplate)XamlReader.Load(#"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""><TextBlock Text=""anniversaries"" FontSize=""54"" Foreground=""Black"" Margin=""-10,0,0,0""></TextBlock></DataTemplate>");
Grid grd = new Grid();
grd.Children.Add(lstAnniversaries);
pan_anniversaries.Content = grd;
PanoramaControl.Items.Add(pan_anniversaries);
EDIT:
Output windows Text
A first chance exception of type 'System.InvalidOperationException' occurred in System.Core.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Core.dll
Step into: Stepping over method without symbols 'System.Reflection.RuntimeMethodInfo.InternalInvoke'
Step into: Stepping over method without symbols 'System.Reflection.MethodBase.Invoke'
Step into: Stepping over method without symbols 'System.Delegate.DynamicInvokeOne'
Step into: Stepping over method without symbols 'System.MulticastDelegate.DynamicInvokeImpl'
Step into: Stepping over method without symbols 'System.Delegate.DynamicInvoke'
Step into: Stepping over method without symbols 'System.Windows.Threading.DispatcherOperation.Invoke'
Step into: Stepping over method without symbols 'System.Windows.Threading.Dispatcher.Dispatch'
Step into: Stepping over method without symbols 'System.Windows.Threading.Dispatcher.OnInvoke'
Step into: Stepping over method without symbols 'System.Windows.Hosting.CallbackCookie.Invoke'
Step into: Stepping over method without symbols 'System.Windows.Hosting.DelegateWrapper.InternalInvoke'
Step into: Stepping over method without symbols 'System.Windows.RuntimeHost.ManagedHost.InvokeDelegate'
A first chance exception of type 'System.Exception' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'System.Exception' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
A first chance exception of type 'MS.Internal.WrappedException' occurred in System.Windows.dll
The thread '<No Name>' (0xf640c32) has exited with code 0 (0x0).
The thread '<No Name>' (0xf450ca6) has exited with code 0 (0x0).
The thread '<No Name>' (0xf050d2e) has exited with code 0 (0x0).
The thread '<No Name>' (0xf820cda) has exited with code 0 (0x0).
The thread '<No Name>' (0xecb0e52) has exited with code 0 (0x0).
Instead of creating DataTemplates in code file, add DataTemplate code in resources section of Page or APP.
Use following way will resolve the problem as #igrali mentioned in the comments
lstAnniversaries.ItemTemplate = this.Resources["AnniversariesTemplate"] as DataTemplate;
lstAnniversaries.Style = this.Resources["EventsListStyle"] as Style;
When editing a XAML file I noticed the following error:
System.ObjectDisposedException occurred
Message=Cannot access a disposed object.
Object name: 'FileCodeModel'.
To debug this I ran another instance of Visual Studios and "Debug-> Attach to Process" to the instance of visual studio where the exception was shown.
I was able to catch the exception in the new Instances that started that is attached to the process. I catch the following exception:
System.ObjectDisposedException occurred
Message=Cannot access a disposed object.
Object name: 'FileCodeModel'.
Source=Microsoft.VisualStudio.CSharp.Services.Language
ObjectName=FileCodeModel
StackTrace:
at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CFileCodeModel.GetCompilation(Boolean fBlockForParses)
at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CPartialTypeCollection.EnumerateParts()
at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CPartialTypeCollection.get_Count()
at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CSlowSnapshot..ctor(CodeElements collection)
at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CPartialTypeCollection.CreateSnapshot()
at Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CCollectionBase.GetEnumerator()
at EnvDTE.CodeElements.GetEnumerator()
at MS.Internal.VSSymbols.SymbolProvider.GetProperties(String fullName, Boolean isTypeDefinition, Boolean useCodeModel)
at Microsoft.Xaml.Symbols.IXamlSymbols.GetProperties(String typeName, Boolean isTypeDefinition, Boolean useCodeModel)
at MS.Internal.Design.Markup.HostedType.BuildProperties(Boolean useCodeModel)
InnerException:
Anybody ever run into this exception in your XAML, and what do you do to fix it.
Are you running a XAML beautifier? - I've had something similar with an extension that cleans XAML up.
This happened to me when I manually grouped a .xaml.cs and .xaml file by editing the .csproj file. To fix this I:
Moved .xaml file to different folder.
Opened up solution.
Removed .xaml from project.
Re-created .xaml file in Visual Studio.
Copied the contents of my original .xaml into the newly created .xaml.
After following these steps I no longer got that error message.
Hey there,
I am clueless in what is causing this but I get an error when my ria service if less than 2 items are been returned, everything works ok if I have 2 or more records been returned.
My domain data source looks like this:
<riaControls:DomainDataSource
AutoLoad="True"
x:Name="dsEmployee"
LoadedData="dsEmployee_LoadedData"
QueryName="GetEmployees">
<riaControls:DomainDataSource.DomainContext>
<my:TestDomainContext />
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
which is been bound to a listbox like this:
<ListBox x:Name="lstEmployees"
ItemsSource="{Binding ElementName=dsEmployee, Path=Data}"
However when I run the application I get this error:
System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'GetEmployees'. Unexpected end of file. Following elements are not closed: IsEnabled, Employee, RootResults, GetEmployeesResult, GetEmployeesResponse. ---> System.Xml.XmlException: Unexpected end of file. Following elements are not closed: IsEnabled, Employee, RootResults, GetEmployeesResult, GetEmployeesResponse.
at System.ServiceModel.DomainServices.Client.WebDomainClient`1.EndQueryCore(IAsyncResult asyncResult)
at System.ServiceModel.DomainServices.Client.DomainClient.EndQuery(IAsyncResult asyncResult)
at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
Has anyone had the same problem? am I doing something wrong here?
This looks like a problem with async server validation failing because it doesn't have enough time to complete. I don't think it is due to anything you did wrong.
There is some discussion of the issue here and some workarounds. Are you using System.Web, if so it sounds like that should not be used on client side code.
http://jeffhandley.com/archive/2010/05/26/asyncvalidation-again.aspx
While trying to answer a question in the vicinity 'Unit Testing WPF Bindings' I had the following niggling question..
What's the best way to find if you have WPF Data Binding wiring setup incorrectly (or you just broke something that was wired up correctly) ?
Although the unit-testing approach seems to be like Joel's 'ripping off your arm to remove a splinter'.. I am looking around for easier less Overhead ways to detect this.
Everyone seems to have committed themselves to data binding in a big way with WPF.. and it does have its merits.
In .NET 3.5 it was introduced a new way to specifically output tracing information about specific data bindings.
This is done through the new System.Diagnostics.PresentationTraceSources.TraceLevel attached property that you can apply to any binding or data provider. Here is an example:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
Title="Debug Binding Sample"
Height="300"
Width="300">
<StackPanel>
<TextBox Name="txtInput" />
<Label>
<Label.Content>
<Binding ElementName="txtInput"
Path="Text"
diag:PresentationTraceSources.TraceLevel="High" />
</Label.Content>
</Label>
</StackPanel>
</Window>
This will put trace information for just that particular binding in Visual Studio's Output Window, without any tracing configuration required.
Best I could find...
How can I debug WPF Bindings? by Beatriz Stollnitz
Since everyone can't always keep one eye on the Output Window looking for Binding errors, I loved Option#2. Which is add this to your App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.Windows.Data" switchName="SourceSwitch" >
<listeners>
<add name="textListener" />
</listeners>
</source>
</sources>
<switches>
<add name="SourceSwitch" value="All" />
</switches>
<sharedListeners>
<add name="textListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="GraveOfBindErrors.txt" />
</sharedListeners>
<trace autoflush="true" indentsize="4"></trace>
</system.diagnostics>
</configuration>
Pair that up with a good regex scan script to extract out relevant info, that you can run occasionally on the GraveOfBindErrors.txt in your output folder
System.Windows.Data Error: 35 : BindingExpression path error: 'MyProperty' property not found on 'object' ''MyWindow' (Name='')'. BindingExpression:Path=MyProperty; DataItem='MyWindow' (Name=''); target element is 'TextBox' (Name='txtValue2'); target property is 'Text' (type 'String')
I use the solution presented here to turn binding errors into native Exceptions: http://www.jasonbock.net/jb/Default.aspx?blog=entry.0f221e047de740ee90722b248933a28d
However, a normal scenario in WPF bindings is to throw exceptions in case the user input cannot be converted to the target type (for instance, a TextBox bound to a integer field; the input of a non-numeric string results in a FormatException, the input of number that is too large results in an OverflowException). A similar case is when the Setter of the source property throws an exception.
The WPF way of handling this is via ValidatesOnExceptions=true and ValidationExceptionRule to signal the user the supplied input is not correct (using the exception message).
However, these exception are also send to the output window and thus 'caught' by the BindingListener, resulting in an error...clearly not the behaviour you'd want.
Therefore, I expanded the BindingListener class to NOT throw an Exception in these cases:
private static readonly IList<string> m_MessagesToIgnore =
new List<String>()
{
//Windows.Data.Error 7
//Binding transfer from target to source failed because of an exception
//Normal WPF Scenario, requires ValidatesOnExceptions / ExceptionValidationRule
//To cope with these kind of errors
"ConvertBack cannot convert value",
//Windows.Data.Error 8
//Binding transfer from target to source failed because of an exception
//Normal WPF Scenario, requires ValidatesOnExceptions / ExceptionValidationRule
//To cope with these kind of errors
"Cannot save value from target back to source"
};
Modified lines in public override void WriteLine(string message):
....
if (this.InformationPropertyCount == 0)
{
//Only treat message as an exception if it is not to be ignored
if (!m_MessagesToIgnore.Any(
x => this.Message.StartsWith(x, StringComparison.InvariantCultureIgnoreCase)))
{
PresentationTraceSources.DataBindingSource.Listeners.Remove(this);
throw new BindingException(this.Message,
new BindingExceptionInformation(this.Callstack,
System.DateTime.Parse(this.DateTime),
this.LogicalOperationStack, int.Parse(this.ProcessId),
int.Parse(this.ThreadId), long.Parse(this.Timestamp)));
}
else
{
//Ignore message, reset values
this.IsFirstWrite = true;
this.DetermineInformationPropertyCount();
}
}
}
You can use the trigger debugging feature of WPF Inspector. Just download the tool from codeplex and attach it to your running app. It also shows binding errors on the bottom of the window.
Very useful tool!
Here's a useful technique for debugging/tracing triggers effectively. It allows you to log all trigger actions along with the element being acted upon:
http://www.wpfmentor.com/2009/01/how-to-debug-triggers-using-trigger.html
This was very helpful to us but I wanted to add to those who find this useful that there is a utility that Microsoft provides with the sdk to read this file.
Found here: http://msdn.microsoft.com/en-us/library/ms732023.aspx
To open a trace file
1.Start Service Trace Viewer by using a command window to navigate to your
WCF installation location (C:\Program
Files\Microsoft
SDKs\Windows\v6.0\Bin), and then type
SvcTraceViewer.exe. (although we found ours in \v7.0\Bin)
Note: The Service Trace Viewer tool
can associate with two file types:
.svclog and .stvproj. You can use two
parameters in command line to register
and unregister the file extensions.
/register: register the association of
file extensions ".svclog" and
".stvproj" with SvcTraceViewer.exe
/unregister: unregister the
association of file extensions
".svclog" and ".stvproj" with
SvcTraceViewer.exe
1.When Service Trace Viewer starts, click File and then point to Open.
Navigate to the location where your
trace files are stored.
2.Double-click the trace file that you want to open.
Note: Press SHIFT while clicking
multiple trace files to select and
open them simultaneously. Service
Trace Viewer merges the content of all
files and presents one view. For
example, you can open trace files of
both client and service. This is
useful when you have enabled message
logging and activity propagation in
configuration. In this way, you can
examine message exchange between
client and service. You can also drag
multiple files into the viewer, or use
the Project tab. See the Managing
Project section for more details.
3.To add additional trace files to the collection that is open, click File
and then point to Add. In the window
that opens, navigate to the location
of the trace files and double-click
the file you want to add.
Also, as for the filtering of the log file, we found these this link extremely helpful:
http://msdn.microsoft.com/en-us/library/ms751526.aspx
For anyone like me looking for a pure programmatic way of enabling all WPF Tracing at a given Trace Level, here is a piece of code that does it. For reference, it's based on this article: Trace sources in WPF.
It doesn't requires a change in the app.config file, and it does not require to change the registry either.
This is how I use it, in some startup place (App, etc.):
....
#if DEBUG
WpfUtilities.SetTracing();
#endif
....
And here is the utility code (by default it sends all Warning to the Default Trace Listener):
public static void SetTracing()
{
SetTracing(SourceLevels.Warning, null);
}
public static void SetTracing(SourceLevels levels, TraceListener listener)
{
if (listener == null)
{
listener = new DefaultTraceListener();
}
// enable WPF tracing
PresentationTraceSources.Refresh();
// enable all WPF Trace sources (change this if you only want DataBindingSource)
foreach (PropertyInfo pi in typeof(PresentationTraceSources).GetProperties(BindingFlags.Static | BindingFlags.Public))
{
if (typeof(TraceSource).IsAssignableFrom(pi.PropertyType))
{
TraceSource ts = (TraceSource)pi.GetValue(null, null);
ts.Listeners.Add(listener);
ts.Switch.Level = levels;
}
}
}
My suggestion at 2021:
The Best way is to use Benoit Blanchon small library from Nuget
His original post at here: https://stackoverflow.com/a/19610384/6296708
His GitHub link and more info about how to use it + Nuget command: https://github.com/bblanchon/WpfBindingErrors
Its features (until now!):
throw exception on binding errors (+ line number)
If source Variable throw any exceptions, this library will catch it and show it.
Unit Test supports too!
Happy Coding!