I just updated to Unity 5 and was trying to build my project for Windows Phone 8. I had the following error:
“ArgumentException: The Assembly mscorlib.Extensions is referenced by UnityUtilitiesWP8 (‘Assets/Plugins/WP8/UnityUtilitiesWP8.dll’). But the dll is not allowed to be included or could not be found.”
Followed by
“Error building Player: Extracting referenced dlls failed.”
The library is built as a “Windows Phone Class Library” targetting Windows Phone 8.0 and is not depending on any third party libraries, only the standard libraries. I have made a stub library as a normal “Class Library” using .NET Framework 3.5, which is used when not on windows phone.
I noticed there is a bunch of settings for files in the plugins folder now.
I have tried the following:
Initially both my stub and the real dll would be included. This failed to build with the message “Plugins colliding with each other.”. Apparently the one in the plugins/WP8 folder will not overwrite the one in the plugins folder automatically anymore.
Then I tried unchecking the “Any Platform” checkbox for both dlls and checking just WP8Player for the real dll and all the others for the stub dll. This failed to build because of compiler errors. It couldn’t find the classes defined in the dlls. As if, at compile time, none of the dlls were there.
Then I noticed the “Placeholder” input for the WP8 library. I set this to point at stub dll. Now it fails with the message “Error building Player: Extracting referenced dlls failed.”
The “Don’t process” checkbox doesn’t seem to make any difference.
Maybe I wasn’t clear about the plugin working fine before updating Unity?
I have not added any references to the plugin, so it is not referencing anything that is not included in the standard platform library.
Why does Unity not allow me to use that dll? Arbitrary limitations like this makes it rather cumbersome to write plugins because you must have a list of what you can/cannot use from the standard platform library.
Would you care to elaborate on that? How do I chose NOT to compile against Silverlight? I’m not even sure what it is or why it is wrong. When creating a project it looks like this:
I see a SILVERLIGHT compilation symbol in the project properties, but removing that and rebuilding the plugin does not remove the error.
I have found the class in the offending assemnbly that I am using: System.Security.Cryptography.ProtectedData, and according to MS docs, it is supported on the platform. So my question remains: Why is Unity not allowing me to use it anymore?
It seems Unity doesn’t know how to locate mscorlib.extensions, so it’s really is a bug, as workaround you could do the following:
Option A
Remove UnityUtilitiesWP8 from Unity project to some other place outside, and reference that plugin from exported solution
Option B
Copy mscorlib.extensions from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.0 and place it next to your plugin, and mark it as WP8 plugin
Also please submit a bug with repro project attached, sorry for inconvience.
I was a little too quick to say that the workaround worked. It compiled, but didn’t work. Probably because it was using the stub dll instead of the real platform one.
I opted to rewrite the code to not use the ProtectedData class.
I thought so too, but an exception is thrown if I do that:
System.TypeInitializationException was unhandled by user code
HResult=-2146233036
Message=The type initializer for ‘WinRTBridge.WinRTBridge’ threw an exception.
Source=WinRTBridge
TypeName=WinRTBridge.WinRTBridge
StackTrace:
at WinRTBridge.WinRTBridge.set_Control(Object value)
at WP8Bug.MainPage…ctor()
InnerException: System.TypeInitializationException
HResult=-2146233036
Message=The type initializer for ‘WinRTBridge.TypeInformation’ threw an exception.
Source=WinRTBridge
TypeName=WinRTBridge.TypeInformation
StackTrace:
at WinRTBridge.TypeInformation…ctor()
at WinRTBridge.WinRTBridge…cctor()
InnerException: System.IO.FileNotFoundException
HResult=-2147024894
Message=Could not load file or assembly ‘mscorlib.Extensions, Version=2.0.5.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.
Source=UnityEngine
FileName=mscorlib.Extensions, Version=2.0.5.0, Culture=neutral, PublicKeyToken=null
StackTrace:
at UnityEngineInternal.BootstrapHelpers.FillTypeMaps(Dictionary2& typeToTypeIdMap, List1& typeIdToTypeMap)
at WinRTBridge.TypeInformation…cctor()
InnerException: