[Universal 10] The type 'X' exists in both 'Windows.Foundation.UniversalApiContract' and 'Windows'

I’ve been trying to port a game to Windows Universal 10 (UAP) for couple days, but haven’t been able to solve the error I’m getting when I’m still compiling scripts during build.

Assets\Analytics\Scripts\Platform-WindowsStore\File.cs(84,30): error CS0433: The type ‘StorageFile’ 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’

Assets\Analytics\Scripts\Platform-WindowsStore\File.cs(97,60): error CS0433: The type ‘CreationCollisionOption’ 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’

The script in case is used by the Google Universal Analytics plugin, although it also happens with GameAnalytics (not the exact same types, but same error).

I’ve been looking for some solutions, but haven’t been able to find much. I’m using Unity 5.3.2p1 (tried with 5.3.1f1 and 5.3.1p4 before and it didn’t help) and I’ve got Windows 10 RTM and Microsoft Emulator for Windows 10 mobile.

I’ve been through these posts:

And according to this post, the problem is that the compiler can’t choose which .dll he should be using (which is strange, since when I use Windows.StorageFile it says it doesn’t exist on the library, and when I use Windows.Foundation.UniversalApiContract.StorageFile, it says the UniversalApiContract doesn’t exist in the library).

I would really appreciate some help.

That’s a weird error: could you post your editor log?

For sure!
(Sorry for the slow reply)

2496011–172369–Editor_log.txt (158 KB)

StorageFile class is in Windows.Storage namespace. The errors are about assemblies, not namespace. Can you try using Windows.Storage.StorageFile. Also, cau you paste a piece of code that causes this issue?

No problem.

I cannot reproduce what you’re seeing - that script compiles and builds for Universal 10 SDK just fine on my machine on 5.3.2p1.

The editor.log says that the only windows.winmd that is referenced is “C:\Windows Kits\10\UnionMetadata\Facade\Windows.winmd”. The error says that StorageFile is defined in that assembly, however, that WinMD file should not define any types at all (it has no types inside on my machine). On my machine, that file is 170 KB. How big is it on yours?

My Windows.winmd is 3.69Mb O-o.

That’s a huge difference. Perhaps you could send me yours so I can try building with it?

PMed. If it works, you should consider SDK reinstall, as something is messed up.

I was able to build the project, although VS doesn’t recognize the Universal Windows Platform Tools and Windows 10 SDK 10.0.10240 (even though I re-installed it like 3 times), so I still can’t build it on the device.

I’d suggest nuking VS2015 and reinstalling it cleanly.

I’m going to try that now.