uwp-desktop
uwp-desktop copied to clipboard
The type forwarder for type 'Windows.Foundation.IAsyncOperation`1' in assembly 'Windows' causes a cycle
I'd like to use await with IAsyncOperation. after I added
c:\Program Files (x86)\Windows Kits\10\UnionMetadata\Facade\Windows.WinMD
c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll
I got:
The type forwarder for type 'Windows.Foundation.IAsyncOperation`1' in assembly 'Windows' causes a cycle
Any updates on this?
This issue is currently crushing my hopes and dreams.
@JamesEarle @bao-qian the instructions in this repo and on the nuget site are wrong. You do not manually add the facade for the API you need. This is what causes the circular reference.
You simply add the full Windows.winmd at C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.16299.0\Windows.winmd
and System.Runtime.WindowsRuntime
. That's it. Note when I say "full", I mean the .winmd
file should be a few megabytes. There's plenty of them with the same name sprinkled around that are a few kb and it's easy to screw up and select one of these.
Then, wherever you call await
on an IAsyncOperation
, make sure you have using System;
in the same source file.
Hope this helps people.
@TechnikEmpire Thank you for clarifying this! I had previously added the "Target Platform = 10" in the .csproj file, then added the UWP references as needed and hit the circular reference issue. Simply doing the two things you recommended fixed the issues (including getting the right version of the .winmd file).
My class library starts to compile when I follow those steps too. But I'm trying to create a nuget package that provides an interface to facilitate a use case that several different WPF applications have that require the interaction with low energy bluetooth devices. When I run this code from a WPF application, I get a PlatformNotSupportedException
thrown complaining about WinRT not being supported on "this" platform.
Is there anything I can do?
What is this host os and build number? Not that not all rt APIs are supported on all builds iirc.
Give details about api as well
I wasn't sure if I was grabbing the right windows.winmd file, so I just grabbed the latest. Does this version matter? Do I need to go to the lowest common version depending on what I'm deploying to?
Someone else will have to answer that but my initial instinct would be that you ought to reference the lowest possible version.
I'll give that a shot when I'm in the office. Thanks for responding!
@jakehockey10 Also make sure you see my remarks here.
@TechnikEmpire Thanks for reaching out! Are you suggesting that I use the window.winmd file from the ...\10.0.16299.0\...
path specifically? Also, when you mention System.Runtime.WindowRuntime
, where are you pulling that in from? Your file system or the NuGet package?
I tried the most earliest version of windows.winmd on my file system and that was version 10.0.15063.0
I can't remember how I referenced windowsruntime, probably just the way the docs say.
I also encountered this error but no luck with any of these solutions in this thread! :(