Reputation: 7320
I'm using Nito.Async both in a PCL framework library and in client app which uses the library. The PCL lib targets .Net4.5 & SL5, and the client is .Net4.5.
If I don't reference Nito.Async in client app, everything is fine. But if I reference it, when i run the app, an MissingMethodException
occurs :
Method not found: 'Microsoft.Runtime.CompilerServices.TaskAwaiter`1<!0> Nito.AsyncEx.AwaitableDisposable`1.GetAwaiter()'
After digging a little more, it seems the problem is msbuild copy the Nito lib from portable-net40
referenced by the PCL lib in the target \bin folder, and then, copy the Nito lib from net45
referenced by the client in the target \bin. So it overwrites the first portable Nito.Async DLL... And when I launch the app, the portable-net40
is replaced by the net45
.
The only few options I see are :
Nito.AsyncEx.Net45.dll
instead of Nito.AsyncEx.dll
(and do it for each distinct target), but I doubt it's a perfect solution.How can I handle this kind of DLL conflict ?
Is there something on the Nuget or MsBuild side already made for this kind of problem ?
Upvotes: 1
Views: 340
Reputation: 16744
The portable version is supposed to be replaced by the net45
version in this case. The MissingMethodException you get means that there's an API compatibility bug in the Nito.AsyncEx package.
Looking at the source code, I'm not sure there's a way to fix this. GetAwaiter()
returns a TaskAwaiter<T>
, but that type has a different identity (it's in a different namespace) for portable libraries targeting Silverlight or .NET 4. I think this was necessary because the constructor is internal so we had to reimplement the class for the portable async support for platforms that didn't have it already.
The simplest fix for this would be to drop support for any platforms which don't already support async from the PCL. So you could target .NET 4.5, WP8, WP8.1, and Windows 8 store apps.
Upvotes: 1