12

Note: This is only a Debug-time error, but a very weird one.

Problem:

While running with Debugger attached and calling a method, exposed in separate Portable library, returning ConfiguredTaskAwaitable, we get InvalidProgramException.

Reproduce It:

Having 2 projects:

  1. PortableClassLibrary (supporting .Net 4.5; Windows Store; Windows Phone 8) with 1 class:

    public class Weird
    {
        public static ConfiguredTaskAwaitable GetConfiguredTaskAwaitable()
        {
            return new ConfiguredTaskAwaitable();
        }
    }
    
  2. ConsoleApplication with code:

    static void Main(string[] args)
    {
        Weird.GetConfiguredTaskAwaitable();
    }
    

Notes:

  1. replacing ConfiguredTaskAwaitable with ConfiguredTaskAwaitable<T> (a generic version) fixes this strange issue
  2. consuming this method form WP8 or Win8 app under Debugger works fine.

Currently it causes problems cause I cant run my Unit Tests under Debugger. I'm forced to change my "ObjectUnderTest" implementation to return generic ConfiguredTaskAwaitable<T>, which is fine for the real project, but still is only a workaround.

The Question is:

Does anybody know the reason for this error? It's definitely related to Portable Class Library magic.

Perception
  • 79,279
  • 19
  • 185
  • 195
Stas Shusha
  • 528
  • 3
  • 11
  • 2
    Have you tried running PEVerify on both assemblies? But this certainly does look like a bug in the compiler or runtime. – svick Dec 05 '12 at 22:19
  • 1
    Just did, for both libs. All verified. But thanks for a useful advice, I didn't know about this utility. – Stas Shusha Dec 06 '12 at 09:27
  • 1
    In that case, you should report it to [Connect](https://connect.microsoft.com/VisualStudio/). – svick Dec 06 '12 at 18:28

1 Answers1

1

Are you using Visual Studio Ultimate 2012 with IntelliTrace enabled? This looks like a bug which should be fixed in the latest CTP of Visual Studio 2012, Update 2 and in future releases.

You can confirm this is the problem (and work around it until you get the fix) by going to Tools/Options/IntelliTrace and turning off 'Enable IntelliTrace'.

Colin Thomsen
  • 1,806
  • 15
  • 11