Search code examples
c#system.reactivelinqpadasync-await

CurrentPlatformEnlightenmentProvider can't be cast to IPlatformEnlightenmentProvider during await on Rx Observable


In a library that I've written I've got a function which creates an Rx ReplaySubject and pushes some things to it from a task, returning the subject as an IObservable for others to watch (it's just publishing some progress updates on the work the task is doing).

I'm then using the library in LINQPad, calling that function, and awaiting the observable:

scenario.SeedAsync(context).Wait();

I then get hit with a TypeInitializationException with the message:

Unable to cast object of type 'System.Reactive.PlatformServices.CurrentPlatformEnlightenmentProvider' to type 'System.Reactive.PlatformServices.IPlatformEnlightenmentProvider'.

From what I can tell these enlightenment providers are a way for Rx to leverage platform specific functionality. I figured that meant it might be a versioning mismatch or something, but I can't find anything obvious. I've checked that the same version of Rx is included on both sides, it's my machine building the library, I'm running the AnyCPU build of LINQPad, but the library is also built for AnyCPU, so I think that should be OK. I'm a bit stumped. I've even tried fiddling with different kinds of subjects and things in the code to make sure it's not specific to any of those.

I haven't been able to find any hint of this error on Google or SO.

Any ideas? I'm not really sure where to look further at this point!


Solution

  • My psychic debugger says that your Rx binaries don't match the versions that are used in Linqpad