Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

WCF in Unity UWP IL2CPP

Discussion in 'Windows' started by MohsenneChaverdie, Jan 3, 2019.

  1. MohsenneChaverdie

    MohsenneChaverdie

    Joined:
    Nov 23, 2016
    Posts:
    39
    For doing that, I followed this old post from Unity Wiki Site.

    Editor

    It works fine.

    UWP -> .Net Scripting Backend

    I have to exclude my supplied
    System.ServiceModel.dll
    from WSA Player, then it works fine.

    UWP -> IL2CPP Scripting Backend on .Net4.x

    With the help of
    System.ServiceModel.dll
    and an
    link.xml
    file, I can get a build from Unity and a successful Compile from VS. But it ends up with this exception:

    Code (CSharp):
    1. NotSupportedException: ..\mscorlib\System.Runtime.Remoting.Proxies\RealProxy.cpp(21) : Unsupported internal call for IL2CPP:RealProxy::InternalGetTransparentProxy - System.Runtime.Remoting is not supported.

    Standalone -> Mono Scripting Backend on .Net4.x

    A successful build in Unity, with a help of a
    link.xml
    file, it works fine.

    I tried:

    On this page and this page and also in this GitHub post Unity says, on IL2CPP backend, stripping on unused assembly engine code is happening and you can make a whitelist by creating a file
    link.xml
    and specify which assemblies should be left untouched. It helps me in case of Standalone Mono but I could not figure it out for IL2CPP.

    Based on this written tutorial about having WCF in Unity, proxy class of the WCF service can be generated with two different Compilers,
    svcutil 
    or
    wsdl
    . The generated .cs class needs
    System.ServiceModel.dll
    the second one needs
    System.Web.Services.dll
    . Both of work fine in Editor but throws two different exceptions with IL2CPP.

    I tested ASP.Net in Unity with IL2CPP backend with the help of
    System.Web.Services.dll
    , based on this written tutorial, but I received the same error code from WCF generated code from wsdl.exe:

    I could be able to bypass
    NullReferenceException: Object reference not set to an instance of an object at System.ServiceModel.MonoInternal.ClientRuntimeChannel..ctor exception
    with this
    link.xm
    l file.

    Conclusion

    There are two possibilities here, either it can be working with a properly written
    link.xml
    file or it is NOT supported on Unity IL2CPP AOT Compiler as of 2018.03.
     
    Last edited: Jan 8, 2019
  2. MohsenneChaverdie

    MohsenneChaverdie

    Joined:
    Nov 23, 2016
    Posts:
    39
    If I set it to Standalone with IL2CPP backend, I am receiving the same Unsupported exception for "System.Runtime.Remoting.dll". So problem is not coming from UWP, but IL2CPP.


    If it is not supported. So how are developers using ASP.Net or WCF in their iOS, Android, UWP applications?
     
  3. stonstad

    stonstad

    Joined:
    Jan 19, 2018
    Posts:
    658
    I'm currently unable to use WCF-related classes (like web services) in IL2CPP builds. I can do it in UWP, of course. But in Unity itself I haven't had much luck at runtime via the player.