Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

System.AccessViolationException is thrown when playing a media #27

Closed
sepehr1014 opened this issue Mar 6, 2015 · 6 comments
Closed

Comments

@sepehr1014
Copy link

When trying to play a video in WPF, I get this exception:
System.AccessViolationException was unhandled
HResult=-2147467261
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=Vlc.DotNet.Core.Interops
StackTrace:
at Vlc.DotNet.Core.Interops.VlcManager.AttachEvent(VlcEventManagerInstance eventManagerInstance, EventTypes eventType, EventCallback callback)
at Vlc.DotNet.Core.VlcMedia.RegisterEvents()
at Vlc.DotNet.Core.VlcMedia..ctor(VlcMediaPlayer player, VlcMediaInstance mediaInstance)
at Vlc.DotNet.Core.VlcMediaPlayer.OnMediaPlayerMediaChangedInternal(IntPtr ptr)
at Vlc.DotNet.Core.Interops.VlcManager.SetMediaToMediaPlayer(VlcMediaPlayerInstance mediaPlayerInstance, VlcMediaInstance mediaInstance)
at Vlc.DotNet.Core.VlcMediaPlayer.SetMedia(VlcMedia media)
at Vlc.DotNet.Core.VlcMediaPlayer.SetMedia(FileInfo file, String[] options)
at Vlc.DotNet.Forms.VlcControl.Play(FileInfo file, String[] options)
at WpfApplication64.MainWindow.btnPlay_Click(Object sender, RoutedEventArgs e) in c:\Visual Studio 2013 Projects\WpfApplication64\WpfApplication64\MainWindow.xaml.cs:line 54
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.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.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.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.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.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at WpfApplication64.App.Main() in c:\Visual Studio 2013 Projects\WpfApplication64\WpfApplication64\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

@sepehr1014
Copy link
Author

That occurs when targeting "Any CPU"

@ghost
Copy link

ghost commented Mar 11, 2015

This exception occurs when closing application after playing video. I find two position will show this exception:

  1. src\Vlc.DotNet.Core.Interops\VlcManager.DetachEvent.cs Line 16; Vlc.DotNet.Core.Interops.VlcManager.DetachEvent(VlcEventManagerInstance eventManagerInstance, EventTypes eventType, EventCallback callback)
    When I close sample application after stop video;
  2. src\Vlc.DotNet.Core.Interops\VlcManager.ReleaseMediaPlayer.cs Line 14; Vlc.DotNet.Core.Interops.VlcManager.ReleaseMediaPlayer(VlcMediaPlayerInstance mediaPlayerInstance)
    When I directly close sample application without stop video.

@sepehr1014
Copy link
Author

@ringboow exactly! I'm getting those two exceptions too!

@ghost
Copy link

ghost commented Mar 11, 2015

And another issue, if we didn't play any video, when closing sample application, it will throw an ArgumentException, position is:
src\Vlc.DotNet.Core.Interops\VlcManager.IsPlaying.cs Line 11;
Vlc.DotNet.Core.Interops.VlcManager.IsPlaying(VlcMediaPlayerInstance mediaPlayerInstance)

I think if we can return false directly without throw any exception ?

@flowerhouse-dev
Copy link

Take a look at this comment regarding the AccessViolationException: #22 (comment)

@jeremyVignelles
Copy link
Collaborator

Old issue, please reopen if still experiencing this issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants