Skip to content

WP8 BackgroundAgent Invalid cross-thread access  #148

@dkarzon

Description

@dkarzon

Windows Phone 8 project
Akavache v3.2.0

Attempting to access the default LocalMachine BlobCache from a WP8 background agent throws UnauthorizedAccessException.
Looks like the exception is coming from ReactiveUI.RxApp when it is not run on a UI thread.

I have created a sample project to show the error. https://dl.dropboxusercontent.com/u/4165510/AkavacheWP8BackgroundTest.zip
Run this project and it will schedule the task and launch it for testing after a few seconds then throw the exception on the getter for BlobCache.LocalMachine

Stack Trace

{System.TypeInitializationException: The type initializer for 'Akavache.BlobCache' threw an exception. ---> System.TypeInitializationException: The type initializer for 'ReactiveUI.RxApp' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.UnauthorizedAccessException: Invalid cross-thread access.
   at MS.Internal.XcpImports.CheckThread()
   at System.Windows.DependencyObject..ctor(UInt32 nativeTypeIndex, IntPtr constructDO)
   at System.Windows.Controls.Border..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at ReactiveUI.DesignModeDetector.IsInDesignMode()
   at ReactiveUI.RxApp.InUnitTestRunner()
   at ReactiveUI.RxApp..cctor()
   --- End of inner exception stack trace ---
   at ReactiveUI.RxApp.get_suppressLogging()
   at ReactiveUI.LogHost.get_Default()
   at Akavache.BlobCache..cctor()
   --- End of inner exception stack trace ---}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions