Search Unity

HttpClient not available in 2018.1 with .NET 4.x

Discussion in 'Scripting' started by NickLandry, May 23, 2018.

  1. NickLandry

    NickLandry

    Joined:
    Oct 12, 2016
    Posts:
    26
    I can't seem to get HttpClient to be recognized in Unity 2018.1.0f2. I tried in both standalone & Android target platforms with the following settings:

    Scripting Runtime version: .NET 4.x equivalent
    Scripting Backend: Mono
    Api Compatibility Level: .NET 4.x

    Based on other forum posts, I added an mcs.rsp file to the root of the Assets folder with the following in it:
    -r:System.Net.Http.dll

    I tried clearing all generated folders (Library, etc.), restarting Unity, nothing works. Unity simply refuses to see the System.Net.Http namespace. What am I missing here?
     
  2. NickLandry

    NickLandry

    Joined:
    Oct 12, 2016
    Posts:
    26
    Interestingly, Unity 2017.4 actually sees the System.Net.Http namespace if I add the mcs.rsp file, but Unity 2018.1 doesn't. So either 2018.1 broke something, or I'm missing the proper way to add support for this namespace in 2018.1. Thanks for any help you can provide with this.
     
  3. NickLandry

    NickLandry

    Joined:
    Oct 12, 2016
    Posts:
    26
    This problem still occurs in Unity 2018.2.0f2 and Unity 2018.1.8f1. PLEASE, what is going on with HttpClient and this namespace? This is a critical part of .NET packages and is used for most cloud communications. Thanks.
     
  4. KevinKeyserHats

    KevinKeyserHats

    Joined:
    Feb 9, 2017
    Posts:
    4
    I am also having problems with System.Net. I tried adding the mcs.rsp file aswell. Is there anyone that knows a fix to getting problems using this namespace? I'm trying to use libraries that use native C# WebRequests. I'm working on version 2018.2.0f2 and tried multiple unity versions before this. Seems like only switching runtime version works, but all my code is C# 6+

    Here's my StackTrace:
    System.NullReferenceException: Object reference not set to an instance of an object
    at System.Net.AutoWebProxyScriptEngine.InitializeRegistryGlobalProxy () [0x0005b] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at System.Net.AutoWebProxyScriptEngine.GetWebProxyData () [0x00007] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at System.Net.WebProxy.UnsafeUpdateFromRegistry () [0x0001a] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at System.Net.WebProxy..ctor (System.Boolean enableAutoproxy) [0x0000d] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at System.Net.WebProxy.CreateDefaultProxy () [0x00012] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at System.Net.Configuration.DefaultProxySectionInternal.GetSystemWebProxy () [0x00000] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at System.Net.Configuration.DefaultProxySectionInternal.GetDefaultProxy_UsingOldMonoCode () [0x00036] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at System.Net.Configuration.DefaultProxySectionInternal.GetSection () [0x00015] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at System.Net.WebRequest.get_InternalDefaultWebProxy () [0x00022] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at System.Net.HttpWebRequest..ctor (System.Uri uri) [0x0008d] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at (wrapper remoting-invoke-with-check) System.Net.HttpWebRequest..ctor(System.Uri)
    at System.Net.HttpRequestCreator.Create (System.Uri uri) [0x00000] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at System.Net.WebRequest.Create (System.Uri requestUri, System.Boolean useUriBase) [0x00091] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at System.Net.WebRequest.Create (System.String requestUriString) [0x00014] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
     
  5. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    966
    Has anyone in this thread reported an issue to the Unity Issues Tracker? Perhaps it may be fixed with a minor update (Like 2018.2.1f1) ?
     
  6. KevinKeyserHats

    KevinKeyserHats

    Joined:
    Feb 9, 2017
    Posts:
    4
    Just sent one out, didn't think I could send a bug report without the Editor crashing. Thank you for pointing that out, just hope this can get fixed.
     
  7. NickLandry

    NickLandry

    Joined:
    Oct 12, 2016
    Posts:
    26
    I filed a bug too. This is very annoying. if anyone finds a workaround please post it back here.
     
  8. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    966
    If there exists a workaround, I predict it's highly likely it will be part of a minor patch.
     
  9. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    478
    @NickLandry what's the error you're getting? Is it compile/edit time, runtime, or build time? Is it in editor code or game code?

    Sam
     
  10. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    966
    For those who did file an issue report, can you share the link, so anyone else viewing this thread can follow up on it?
     
    samizzo likes this.
  11. MaxXR

    MaxXR

    Joined:
    Jun 18, 2017
    Posts:
    60
    Bump - same issue here.
    2018.2.2f1
     
  12. KevinKeyserHats

    KevinKeyserHats

    Joined:
    Feb 9, 2017
    Posts:
    4
    My bug ended up being a bug in mono. I found that Mono and .Net have different actions taken when the registry on window's computers have proxy server enabled without a proxy server url. Mono errors out and .Net just continues as if it wasn't using proxy. I submitted the bug to Mono with the fix and hope that they will get to it because its an easy one liner.
     
  13. minhdtb

    minhdtb

    Joined:
    Sep 15, 2017
    Posts:
    1
    Bump, I have the same issue here, please fix 2018.2.1f1
     
  14. patrick_scheper

    patrick_scheper

    Joined:
    Mar 18, 2015
    Posts:
    16
    Please fix.
     
  15. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    14,417
  16. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    966
    Well, it's fixed, so that's great. I'm guessing it's 2018.3?
     
    patrick_scheper likes this.