I'm trying to build to Win10 from Unity 5.2f3 and keep running into issues with .NET types that have been duplicated in WinRTLegacy (e.g. XmlDocument, System.IO.Directory/File): Code (CSharp): error CS0433: The type 'Directory' exists in both 'System.IO.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'WinRTLegacy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' I've tried a bunch of variants of the suggested fix below, but haven't gotten anything to play nicely when I actually build. I admit I don't fully understand how 'usings' work. Code (CSharp): #if NETFX_CORE using IO = WinRTLegacy.System.IO; #else using IO = System.IO; #endif Any help would be appreciated!
Hi, we're aware of this issue... there is a fix, but it will be only be available in 5.2p2. There's no workarounds as far as I know... You could submit a bug report with repro case, so we would be sure it fixes your issue as well.
If you don't have a lot of code that uses these conflicting classes, you could make this workaround: 1. Build an empty Unity project for Windows 10, find WinRTLegacy.dll in the built Visual Studio project. 2. Drop WinRTLegacy.dll into your normal Unity project (Plugins/WSA/). Mark it as "don't process" in Unity and tick only the WSA checkbox. 3. Add a file named csc.rsp directly in your Assets folder and put this line in it: /reference:WinRTLegacyTMP=Assets/Plugins/WSA/WinRTLegacy.dll 4. In scripts that use conflicting classes, at the very top, add: #if NETFX_CORE extern alias WinRTLegacyTMP; #endif 5. In each file that uses conflicting classes for every conflicting class, also add these after other "using" statements: #if NETFX_CORE using ConflictingClassName = WinRTLegacyTMP::Full.Namespace.ConflictingClassName; #endif It's not pretty, but if you need to build it and cannot wait for the fix, it's better than nothing.
I got same error previously Code (csharp): error CS0433: The type'File' exists in both 'System.IO.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'WinRTLegacy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' With DominoOne solution the error disappeared, but I got new error: Code (csharp): error CS0234: The type or namespace name 'Full' does not exist in the namespace 'WinRTLegacyTMP' (are you missing an assembly reference?) Any solutions?
You do not need to write "Full" in the namespace You just have to write the full namespace instead. E. g. for the File class you have to write: #if NETFX_CORE using File = WinRTLegacyTMP::System.IO.File; #endif If you have other conflicting classes, you'll need to write a similar line for each of them.
Thanks for the quick response But now the old error popped back and got new error: Code (csharp): Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded. at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool) at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0 at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0 at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0 at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0 at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0 at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 The following assembly referenced from C:\YYY\Assets\Plugins\WSA\WinRTLegacy.dll could not be loaded: Assembly: System.Runtime (assemblyref_index=0) Version: 4.0.20.0 Public Key: b03f5f7f11d50a3a The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (C:\YYY\Assets\Plugins\WSA\). Could not load file or assembly 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Missing method .ctor in assembly C:\YYY\Assets\Plugins\WSA\WinRTLegacy.dll, type System.Runtime.Versioning.TargetFrameworkAttribute Can't find custom attr constructor image: C:\YYY\Assets\Plugins\WSA\WinRTLegacy.dll mtoken:
Hm.. Did you mark WinRTLegacy.dll as only used for WSA? I didn't mention that in the steps, but I think that was necessary.
Yes, thanks, that caused that Unhandled Exception error, but the original error unfortunately appears anyway :/ Code (csharp): Assets\Scripts\AssetStreamer.cs(28,22): error CS0433: The type 'File' exists in both 'System.IO.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'WinRTLegacy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' Guess, I should wait for 5.2p1
Could you paste the code of the AssetStreamer.cs script? I could check it out to see if everything's in place for the workaround to work.
Code (csharp): #if NETFX_CORE extern alias WinRTLegacyTMP; #endif using UnityEngine; using System.Collections; #if NETFX_CORE using File = WinRTLegacyTMP::System.IO.File; #endif public class AssetStreamer : MonoBehaviour { private void Start (){ string path = Application.dataPath + "/StreamingAssets"; } public string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "MyFile"); public string result = ""; IEnumerator Example() { if(filePath.Contains("://")) { WWW www = new WWW(filePath); yield return www; result = www.text; } else result = System.IO.File.ReadAllText(filePath); } } I could not paste all code, because forum said that it contains spam-like or inappropriate content, but here is the part that contains error
OK, since you're using the full namespace before class names (e. g. System.IO.File.ReadAllText(filePath)), try adding this: #if NETFX_CORE using System = WinRTLegacyTMP::System; #endif If that doesn't help, you could remove "System.IO." before "File" (e. g. result = File.ReadAllText(filePath).
Sadly that fix missed 5.2.0p1, it should be in 5.2.1p1 which should be released in Sep 23. Sorry for inconvience
It's placed here - Editor\Data\PlaybackEngines\metrosupport\Managed\UAP, I doubt you can remove it, but you probably can provide an empty assembly instead No promises, that it'll work though
Still having the same issue on 5.2.1f1 Is this supposed to be fixed in p1? and when will that be out. Thanks!
Finally 5.2.1p1 is out But now i have the problem when i use WinRTLegacy i get an error because the namespace WinRTLegacy.IO is missing Code (CSharp): #if NETFX_CORE using StreamWriter = WinRTLegacy.IO.StreamWriter; #endif
Use regular StreamWriter, something like Code (csharp): #if NEFTFX_CORE && !WINDOWS_UWP using StreamWriter = WinRTLegacy.IO.StreamWriter; #else using System.IO; #endif
I get many errors with the regular StreamWriter on UWP. That's the reason why i wanted to use WinRTLegacy.IO.StreamWriter instead
The constructor of StreamWriter is different in .NET Core 5. Also the method Close() is removed, but this can be probably simply fixed by using Dispose() instead.
Using Unity 5.2.1f1 and still seeing this issue. I tried DominoOne's solution and it did allow Unity to create the Win10 Universal solution, which I then tried to open in Visual Studio 2015. Visual Studio is now throwing exceptions for each externalias WinRTLegacyTMP; usage saying... The extern alias 'WinRTLegacyTMP' was not specified in a /reference option I see the csc.rsp file in the Assets folder, I even tried to add it to the project, but it seems like the solution is ignoring it when it tries to build. Any other thoughts?
I've been struggling ever since U5.2.0 got released to get StreamWriter to work... and after all this time you are telling me the solution was simply to sit back and wait then download a new version of Unity? Omg... If only I had known this from the beginning.... Let me go download the latest version and see if my (proven)working code finally compiles again! +1 on this bandwidth heavy but simple solution! P.s. I am new to Windows development and the porting guides just say "Coming soon". Any idea when "soon" might be? Thanks
Think I might have gotten it... I needed to right click the WinRTLegacy DLL and select properties. Then I changed the Aliases to WinRTLegacyTMP. Many of the errors went away - leaving me with unrelated errors. I'll continue trying to fix those and hopefully get a compiling WinUniversal 10 app!
The type 'SocketErrorStatus' exists in both 'Windows.Foundation.UniversalApiContract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' and 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' Many of the errors are gone, but errors like this still exist. Any solution for these errors? These seem similar to the WinRTLegacy issues...
I'm getting a similar issue with 'IOrderedDictionary': Assets\Shared\AWSSDK\src\Core\ThirdParty\Json\IJsonWrapper.cs(53,75): error CS0433: The type 'IOrderedDictionary' exists in both 'System.Collections.Specialized, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'WinRTLegacy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' This is on 5.2.1p1 AND 5.2.1p2.
Somehow we missed this type, we'll remove it from WinRTLegacy in upcoming patch release, in the mean time, try unzipping this WinRTLegacy, and place them in <5.2.1p2 installation path>\Editor\Data\PlaybackEngines\metrosupport\Managed\UAP and see if the works. (Backup previous WinRTLegacy.dll and WinRTLegacy.pri) and see if that works.
Ok great, thanks! A related issue that seems to not involve WinRTLegacy: Assets\Shared\InControl\Source\Utility\Utility.cs(244,4): error CS0433: The type 'StorageFolder' exists in both 'Windows.Foundation.UniversalApiContract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' and 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' This and a few other classes (StorageFile, FileIO, and CreationCollisionOption) are keeping me from compiling to Windows 10 Universal right now (These are all in the InControl Asset Store plugin so I imagine it could affect quite a few people). Looks like its conflicted between Windows and Windows.Foundation.UniversalApiContract? Any thoughts/fixes for this?