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:
PortableClassLibrary (supporting .Net 4.5; Windows Store; Windows Phone 8) with 1 class:
public class Weird { public static ConfiguredTaskAwaitable GetConfiguredTaskAwaitable() { return new ConfiguredTaskAwaitable(); } }
ConsoleApplication with code:
static void Main(string[] args) { Weird.GetConfiguredTaskAwaitable(); }
Notes:
- replacing
ConfiguredTaskAwaitable
withConfiguredTaskAwaitable<T>
(a generic version) fixes this strange issue - 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.