Reference Rewriter error building for Windows Store in Unity

Lotus
Lotus
edited July 2015 in DotNet
Hi,

I'm using Photon Server (not PUN) in Unity and I can build fine for PC. However, when I try to build a Windows Store Universal app or Windows Phone 8 app in Unity 5, I get thousands of "Reference Rewriter" errors pointing to Photon3Unity3D.dll (see below).

Does this mean I'm referencing the wrong DLL (or referencing it incorrectly)? If so, what's the recommended way to do it? Is there an AddOn that I should be using?

Thank you.

Universal (thousands of similar errors like this)
Reference Rewriter: Error: type `System.Console` doesn't exist in target framework. It is referenced from Photon3Unity3D.dll at System.Void Photon.SocketServer.Numeric.BigInteger::RSATest(System.Int32).

Window Phone
Reference Rewriter: Error: method `System.Int32 System.Net.Sockets.Socket::Receive(System.Byte[],System.Int32,System.Int32,System.Net.Sockets.SocketFlags)` doesn't exist in target framework. It is referenced from Photon3Unity3D.dll at System.Void ExitGames.Client.Photon.SocketTcp::ReceiveLoop().

Comments

  • Windows Store Universal apps are a bit tricky to support. Those need their own dll (different compile) and that has to be setup in Unity correctly. Right now, there is no out of the box package that does this.
    If you are OK with it, I can PM you a link to a package of libs which should help. They might not be the version you have but should be compatible. You should be able to set them up for export and try them out...
  • Thank you, I'll give them a try and see if they work.
  • I still couldn't get the universal app to build. I get errors about not finding the -firstPass DLLs.

    I tried instead to build WSA 8.1, but I'm getting SerializationWeaver errors as below. Were you able to get it working on either the WSA 8.1 or the Universal 8.1 (or UAP) ?

    Error details:
    Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Photon3Unit
    y3D, Version=4.0.0.9, Culture=neutral, PublicKeyToken=null'
    at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, Reader
    Parameters parameters)
    at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
    at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
    at Mono.Cecil.TypeReference.Resolve()
    at Unity.SerializationLogic.UnityEngineTypePredicates.IsUnityEngineObject(Typ
    eReference type)
    at Unity.Serialization.Weaver.MethodEmitterBase.WillUnitySerialize(FieldDefin
    ition fieldDefinition)
    at Unity.Serialization.Weaver.SerializeMethodEmitter.ShouldProcess(FieldDefin
    ition fieldDefinition)
    at System.Linq.Enumerable.<>c__DisplayClassf`1.<CombinePredicates>b__e(TSourc
    e x)
    at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
    at Unity.Serialization.Weaver.MethodEmitterBase.EmitMethodBody()
    at Unity.Serialization.Weaver.SerializeMethodEmitter.SerializeMethodDefinitio
    nFor(TypeDefinition typeDef, SerializationBridgeProvider serializationBridgeProv
    ider)
    at Unity.Serialization.Weaver.SerializationWeaver.AddSerializeMethod()
    at Unity.Serialization.Weaver.SerializationWeaver.Weave()
    at usw.Weaver.WeaveAssembly(String assemblyPath, AssemblyDefinition unityEngi
    neAssemblyDefinition)
    at usw.Weaver.Weave()
    at usw.Program.RunProgram(ConversionOptions options)
    at usw.Program.Main(String[] args)
  • I can try to take a look asap. Please let us know which Unity version you are using exactly. Patch or no? 5 or 4?
    You should try the latest patch version for your Unity.
  • I tried with multiple versions including 5.0.1p4 and 5.0.1f1. But eventually just gave up on building the C# projects as that seemed to be bugged in the latest versions of Unity. The problem wasn't there on some flavor of 5.1 but that had its own problems.
  • So you're in the beta group?
    If it's gone in 5.1, this seems to be some kind of Unity issue. We can rarely work around those, if things go this kind of wrong.
    I hope the 5.1 problems get sorted and you can build again.
    Please update us on the state or if you have something we can help with.
  • Sent a PM.

    Thanks.
  • Hi,

    I am also interested in compiling my Unity 5 game to Windows Phone 8.1, but I am getting the same errors.

    Did you manage to get it to work?

    I am using Unity version 5.1.1f1.

    Cheers.
  • Sorry, I have to ask:
    You want to build for Windows Store, Windows Phone 8.1, right?
    If you use the Photon Unity SDK, I would have to update it, still. I can do that this week, I assume.

    If you use PUN:
    Please update to PUN 1.58 from the Asset Store.
    Make sure the import defines your dll export configuration (in doubt, try a demo in a new, empty project). It should look like this:


    All other dlls should not export to WSA (Windows Store Assembly?!).


    It built fine for me in your Unity version. Right now, I don't have a device to test run it, though.
  • Hi Tobias,

    I use PUN, so I deleted the previous "Photon Unity Networking" folder from my project and downloaded the latest PUN from the Unity Asset Store.

    I also configured the Photon3Unity3D import settings as you show in the picture (it was already OK).

    However, I get two errors:

    Assets/Plugins/ChatApi/ChatClient.cs(32,31): error CS0433: The imported type `ExitGames.Client.Photon.IPhotonPeerListener' is defined multiple times
    Assets/Plugins/ChatApi/ChatPeer.cs(16,31): error CS0433: The imported type `ExitGames.Client.Photon.PhotonPeer' is defined multiple times

    Any ideas?
  • Tobias
    Tobias admin
    edited July 2015
    The image above shows the setup for one of the dlls (Metro one). Note that there is a Placeholder defined for it. This keeps Unity from thinking that there are multiple definitions.
    If there are actually too many .dll files in your project due to the import/copy, you need to manually find the duplicates and clean your project.
  • I managed to remove all duplicates and reinstalled to the latest PUN version successfully.

    The PhotonUnity3D import settings are defined as you show in the image but I'm still getting reference rewritter errors. Here you got some of them:

    "Reference rewriter: Error: method `System.Byte[] System.IO.File::ReadAllBytes(System.String)` doesn't exist in target framework. It is referenced from Assembly-CSharp.dll at System.Byte[] NGUITools::Load(System.String)..."


    "Reference rewriter: Error: method `System.Void System.Xml.Linq.XDocument::Save(System.String)` doesn't exist in target framework. It is referenced from Assembly-CSharp.dll at System.Void..."


    "Reference rewriter: Error: type `System.Net.Sockets.TcpClient` doesn't exist in target framework..."



    "UnityException: Failed to run assembly converter with command -platform=wp80..."

    "Error building Player: UnityException: Failed to run assembly converter with command -platform=wp80..."


    Any ideas?
  • At least some of those errors are from NGUI instead of PUN.
    Did you try to export a PUN demo after importing the package in a new, empty project? I think we are not using Linq, that TCP class, etc.
    I am not at a Windows 8.1 machine today but I can take a look tomorrow. Now that you say the export settings are ok, I will have to take another look.
    I think the dll from the plugins "*RT*" folder should be ok for a universal build. Maybe I missed something.
  • I have followed this refernec from the image



    I still got the following error

    Plugin 'Photon3Unity3D.dll' is used from several locations:
    Assets/Plugins/Metro/Photon3Unity3D.dll would be copied to /Photon3Unity3D.dll
    Assets/Plugins/Photon3Unity3D.dll would be copied to /Photon3Unity3D.dll
    Please fix plugin settings and try again.

    UnityEditor.Modules.DefaultPluginImporterExtension:CheckFileCollisions(String)
    UnityEditorInternal.PluginsHelper:CheckFileCollisions(BuildTarget) (at C:/buildslave/unity/build/Editor/Mono/Plugins/PluginsHelper.cs:25)
    UnityEditor.HostView:OnGUI()
  • SaravanaKumar
    SaravanaKumar ✭✭
    edited July 2015
    I'm using Unity Latest Version 5.1.2f1.

    Chat Unity3D SDK downloaded from thislink.

    I tried to build the 'demo-photon-chat'

    It shows the same error as above. For Windows Universal Apps.

  • The error points to issues with duplicate dlls. You setup the metro dll just fine, but maybe you didn't setup the dll which is just the placefolder?

    Please try this setup:

    \Plugins\WP8\Photon3Unity3D.dll
    -> Check only WP8Player under platform (any CPU). Add a "Placeholder": \Plugins\Photon3Unity3D.dll. Leave "Don't process" off (as last resort, you could try to check that).

    \Plugins\Photon3Unity3D.dll
    -> Check all platforms except WP8, WSA and Blackberry.

    \Plugins\Metro\Photon3Unity3D.dll
    -> Check only platform WSAPlayer. I did not run this now. Focus is on WP8.

    \Plugins\WebSocket\websocket-csharp.dll
    -> Only platform is Editor.
  • That one works fine. But after completion of build. I got .sln file for Windows Universal Build and It shows following error.

    This error is repeating.

    Reference rewriter: Error: method `System.Void System.Console::Write(System.String)` doesn't exist in target framework. It is referenced from Photon3Unity3D.dll at System.Void Photon.SocketServer.Numeric.BigInteger::RSATest2(System.Int32).
    UnityEngine.Debug:LogError(Object)
    PostProcessWinRT:RunReferenceRewriter() (at C:/buildslave/unity/build/PlatformDependent/WinRT/SharedSources/CSharp/PostProcessWinRT.cs:503)
    PostProcessUniversal81:RunReferenceRewriter() (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessUniversal81.cs:118)
    PostProcessWinRT:Process() (at C:/buildslave/unity/build/PlatformDependent/WinRT/SharedSources/CSharp/PostProcessWinRT.cs:98)
    PostProcessUniversal81:Process() (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessUniversal81.cs:42)
    UnityEditor.HostView:OnGUI()

    Reference rewriter: Error: type `System.Console` doesn't exist in target framework. It is referenced from Photon3Unity3D.dll at System.Void Photon.SocketServer.Numeric.BigInteger::RSATest2(System.Int32).
    UnityEngine.Debug:LogError(Object)
    PostProcessWinRT:RunReferenceRewriter() (at C:/buildslave/unity/build/PlatformDependent/WinRT/SharedSources/CSharp/PostProcessWinRT.cs:503)
    PostProcessUniversal81:RunReferenceRewriter() (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessUniversal81.cs:118)
    PostProcessWinRT:Process() (at C:/buildslave/unity/build/PlatformDependent/WinRT/SharedSources/CSharp/PostProcessWinRT.cs:98)
    PostProcessUniversal81:Process() (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessUniversal81.cs:42)
    UnityEditor.HostView:OnGUI
  • It seems now you're building with the WP8 dll but you have to use the RT (or Metro) one. That doesn't have the Console.Write output.

    Can you check the setup for the dlls and see if you can define which lib goes into the Universal build?
  • I'm currently building for Universal Windows. So, I did the following setup as you mentioned in the previous reply


    \Plugins\WP8\Photon3Unity3D.dll
    -> Check only WP8Player under platform (any CPU). Add a "Placeholder": \Plugins\Photon3Unity3D.dll. Leave "Don't process" off (as last resort, you could try to check that).

    \Plugins\Photon3Unity3D.dll
    -> Check all platforms except WP8, WSA and Blackberry.


    Here is the same kind of errors I'm getting.
    Reference rewriter: Error: type `System.Console` doesn't exist in target framework. It is referenced from Photon3Unity3D.dll at System.Void Photon.SocketServer.Numeric.BigInteger::MulDivTest(System.Int32).
    UnityEngine.Debug:LogError(Object)
    PostProcessWinRT:RunReferenceRewriter() (at C:/buildslave/unity/build/PlatformDependent/WinRT/SharedSources/CSharp/PostProcessWinRT.cs:507)
    PostProcessWinRT:Process() (at C:/buildslave/unity/build/PlatformDependent/WinRT/SharedSources/CSharp/PostProcessWinRT.cs:98)
    UnityEditor.HostView:OnGUI()

    and Some more errors.
  • Now I'm trying in Unity 5.1.3f1
  • I think for Universal Windows, you can only use the RT variant of the DLLs but you use the WP8 one.
    As far as I can see now, the RT variant doesn't have our BigInteger implementation in it, so at least that error couldn't happen anymore.