'MethodAccessException' when using Async for WP7.5 version 1.0.12-beta - by nuwandapl

Status : 


Sign in
to vote
ID 774617 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 12/17/2012 11:20:02 PM
Access Restriction Public


I am using Microsoft.Bcl.Async package v. 1.0.12-beta in a Windows Phone 7.5 project. I am able to work with it but at times it starts to fail with the exception attached at the end. The issue seems to be related to debugging as I can start and use the deployed application on my device but when I try to debug it with Visual Studio 2012 the exception occurs when the code reaches the statement using await. I was able to fix the issue couple of times by reinstalling the package and restarting Visual Studio. 

System.MethodAccessException occurred
  Message=Attempt to access the method failed: System.Environment.get_ProcessorCount()
       at System.Delegate.InternalCreateDelegate(Type type, Object firstArgument, MethodInfo method, StackCrawlMark& scm)
       at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method)
       at System.LightupServices.CreateDelegate(Type type, Object instance, MethodInfo method)
       at System.Lightup.CreateMethodAccessor(Type type, String name)
       at System.Lightup.GetMethodAccessor(Delegate& storage, Type type, String name)
       at System.Lightup.GetMethodAccessor[T](Delegate& storage, String name)
       at System.Lightup.TryCall[T](Delegate& storage, String methodName, Int32& returnValue)
       at System.Lightup.TryGet[T](Delegate& storage, String propertyName, Int32& value)
       at System.EnvironmentLightup.TryGetProcessorCount(Int32& count)
       at System.EnvironmentLightup.get_ProcessorCount()
       at System.Threading.PlatformHelper.get_ProcessorCount()
       at System.Collections.Concurrent.ConcurrentDictionary`2.get_DefaultConcurrencyLevel()
       at System.Collections.Concurrent.ConcurrentDictionary`2..ctor()
       at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
       at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
       at System.Activator.InternalCreateInstance(Type type, Boolean nonPublic, StackCrawlMark& stackMark)
       at System.Activator.CreateInstance(Type type)
       at System.Threading.LazyInitializer.LazyHelpers`1.ActivatorFactorySelector()
       at System.Threading.LazyInitializer.EnsureInitializedCore[T](ConcurrentDictionary`2& target, Func`1 valueFactory)
       at System.Threading.LazyInitializer.EnsureInitialized[T](ConcurrentDictionary`2& target)
       at System.Threading.Tasks.TaskScheduler.RegisterTaskScheduler(TaskScheduler ts)
       at System.Threading.Tasks.TaskScheduler..ctor()
       at System.Threading.Tasks.ThreadPoolTaskScheduler..ctor()
       at System.Threading.Tasks.TaskScheduler..cctor()
       at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.PreventUnobservedTaskExceptions()
       at System.Runtime.CompilerServices.AsyncVoidMethodBuilder..cctor()
       at Cofinite.WindowsPhone.MaklerGPW.ViewModels.MainPageViewModel.Startup()
       at Cofinite.WindowsPhone.MaklerGPW.ViewModels.MainPageViewModel.OnViewReady(Object view)
       at Caliburn.Micro.FrameAdapter.<>c__DisplayClass8.<OnNavigated>b__5(Object , EventArgs )
       at System.Windows.FrameworkElement.OnLayoutUpdated(Object sender, EventArgs e)
       at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)
Sign in to post a comment.
Posted by Microsoft on 1/8/2013 at 2:47 PM

Thanks for the bug, this will be fixed in the next update of the package.
Posted by nuwandapl on 12/18/2012 at 9:32 AM
It seems that this exception is always thrown and I had 'Break on all CLR exception when thrown' setting turned on. But on the other hand there is nothing about this first-chance exception in the debug log.
Posted by Microsoft on 12/18/2012 at 1:13 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Microsoft Visual Studio Connect Support Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 12/17/2012 at 11:50 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)