What's wrong with consuming ConfiguredTaskAwaitable from PortableClassLibrary's class under Debugger from MSTest Runner or Console App?
Posted
by
Stas Shusha
on Stack Overflow
See other posts from Stack Overflow
or by Stas Shusha
Published on 2012-12-05T15:19:45Z
Indexed on
2012/12/06
5:04 UTC
Read the original article
Hit count: 200
*Its only 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
.
Repro:
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 knows the reason of this error? It definitely related to Portable Class Library magic.
© Stack Overflow or respective owner