When I updated my Windows Phone 7.1 app to Visual Studio 2012, I expected everything to be fine. It was not to be.
I was using the Async Targeting Pack with Visual Studio 2010, this pack is not supported on Visual Studio 2012. Initially this did not give an error, till I changed my Build mode to “release”.
The Async Targeting Pack has been replaced with Microsoft.Bcl.Async which is available on nuget. Also ensure that you have nuget package manager 2.2 update and the Microsoft.Bcl.Async version is 1.0.12 beta. I did all the changes but then I encountered an unusual problem. The app was building correctly, but when running on the WP 7.1 emulator, it was throwing an Method Access exception like:
Attempt to access the method failed: System.Environment.get_ProcessorCount()
This error did not come on the WVGA , WXGA, 720p emulators. Googling also did not help much. Finally I created another app with a simple usage of the Task Parallel Library (TPL). To my surprise this did not throw any error and worked fine.
Then I thought that it could be some problem with my project as it had come from Visual studio 2010. I took a backup of all files and deleted the project. Then I created another WP 7.1 project and added all the files and references one by one. After all this effort, it worked.
When I compared the two project files, there was not much difference that I could point to as the “problem”. In any case the problem was resolved and that was the goal. Hope this helps.
- Windows Phone Toolkit overview (blogs.windows.com)
- TWC9: Visual Studio 2012 Update 1, Windows Phone 8, Hilo and more… | This Week On Channel 9 (channel9.msdn.com)