Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

System.Net.Http

Discussion in 'Experimental Scripting Previews' started by Jeremy-Lv, Mar 23, 2018.

  1. Jeremy-Lv

    Jeremy-Lv

    Joined:
    Mar 17, 2013
    Posts:
    16
    Can any one help to use 4.6 net.http??
    upload_2018-3-23_10-43-0.png
    upload_2018-3-23_10-43-9.png
    upload_2018-3-23_10-43-22.png

    Unity Version is 2017.1.1f1,2017.3.1p3.

    Can any one help?
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    You will need to manually add a reference to the System.Net.Http.dll assembly in the .NET class libraries (Unity does not reference it by default). You can do this by adding an mcs.rsp file in the Assets folder of your project with these contents:

    -r:System.Net.Http.dll
     
    Muhahaha100 likes this.
  3. Jeremy-Lv

    Jeremy-Lv

    Joined:
    Mar 17, 2013
    Posts:
    16
    Thanks a lot ~ I have already saw you relay on the same issue in other same forums,But it's seems only without compile error. When I use HttpClient.setVersion (2,0) ,what I realy want to use http2 to save tcp connection count ,it show me a exception .With the version(1,0) or (1,1) it can run and get the http server data.
    I am not sure if I should continue to find a way to use unity dnet4.6 httpclient for my http2 request or find another way ..
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    I'm unsure about the status of http2 support. I would recommend creating a test case which does what you want, then see if it works with .NET outside of Unity. If it does work there, but not in Unity, then please file a bug report.
     
  5. Gigaflops2017

    Gigaflops2017

    Joined:
    Jan 11, 2018
    Posts:
    4
    This gives me:
    Code (CSharp):
    1. error CS0006: Metadata file `System.Net.Http.dll' could not be found
    2.  
    3. Compilation failed: 1 error(s), 0 warnings
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Which Scripting Runtime Version and Api Compatibility Level values are you using the the Player Settings?
     
  7. Gigaflops2017

    Gigaflops2017

    Joined:
    Jan 11, 2018
    Posts:
    4
    Nevermind, after I deleted library and temp files this is no longer an issue.
    Android, .Net 4.x equivalent, Mono.
     
    JoshPeterson likes this.
  8. dptaf

    dptaf

    Joined:
    Sep 23, 2022
    Posts:
    14
    hi @JoshPeterson -- do you have any additional info on the purpose of the mcs.rsp file?
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    The mcs.rsp file is used to provide additional command line arguments to the C# compiler. In all currently supported versions of Unity, the file should be named csc.rsp, since Unity now uses csc.exe (i.e. Roslyn) as the C# compiler in all cases.
     
  10. dptaf

    dptaf

    Joined:
    Sep 23, 2022
    Posts:
    14
    many thanks
     
  11. dptaf

    dptaf

    Joined:
    Sep 23, 2022
    Posts:
    14
    hey @JoshPeterson -- one additional question, does it matter where i place the actual .dll within the project?
     
  12. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    In general no, it does not matter. But which .dll file are you putting in the project? Sorry, I may have missed something.
     
  13. dptaf

    dptaf

    Joined:
    Sep 23, 2022
    Posts:
    14
    I'm trying to make use of System.Net.Http.WebRequest.dll. Specifically, the ClientCertificateOptions in the WebRequestHandler
     
  14. dptaf

    dptaf

    Joined:
    Sep 23, 2022
    Posts:
    14
    seeing this after doing the unity build upload_2022-11-16_10-26-46.png
     
  15. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Ahh ok! So should not need to copy System.Net.Http.WebRequest.dll into the Unity project. Just referencing it from the csc.rsp should be enough to use it properly.
     
    dptaf likes this.
  16. dptaf

    dptaf

    Joined:
    Sep 23, 2022
    Posts:
    14
    what's peculiar is that when running the code within the editor, everything works as expected. i only see this when when doing the actual build
     
  17. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Can you send the text of those error messages? I don't see all of the text in the screen shot.
     
  18. dptaf

    dptaf

    Joined:
    Sep 23, 2022
    Posts:
    14
    gotcha -- let me give it a shot without the dll being there
     
  19. dptaf

    dptaf

    Joined:
    Sep 23, 2022
    Posts:
    14
    sure, here's one of the error messages

    Reference rewriter: Error: method `System.Void System.Net.Http.HttpClientHandler::CheckDisposedOrStarted()` doesn't exist in target framework. It is referenced from System.Net.Http.WebRequest.dll at System.Void System.Net.Http.WebRequestHandler::set_AuthenticationLevel(System.Net.Security.AuthenticationLevel).
    0x00007ff762f7c4cc (Unity) StackWalker::GetCurrentCallstack
    0x00007ff762f83ac9 (Unity) StackWalker::ShowCallstack
    0x00007ff763d1ad5c (Unity) GetStacktrace
    0x00007ff76478b677 (Unity) DebugStringToFile
    0x00007ff7630fe9ca (Unity) DebugLogHandler_CUSTOM_Internal_Log
    0x000001fe805cbd4b (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
    0x000001fe805cbbeb (Mono JIT Code) UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
    0x000001fe805cb10e (Mono JIT Code) UnityEngine.Logger:Log (UnityEngine.LogType,object)
    0x000001fe86ca94ea (Mono JIT Code) UnityEngine.Debug:LogError (object)
    0x000001fe86ca2123 (Mono JIT Code) [PostProcessWinRT.cs:1196] PostProcessWinRT:RunReferenceRewriter ()
    0x000001fe86a9e9e3 (Mono JIT Code) [PostProcessWinRT.cs:203] PostProcessWinRT:process ()
    0x000001fe86a9724b (Mono JIT Code) [ExtensionModule.cs:86] UnityEditor.UWP.BuildPostprocessor:postProcess (UnityEditor.Modules.BuildPostProcessArgs)
    0x000001fe86a96f2e (Mono JIT Code) UnityEditor.Modules.DefaultBuildPostprocessor:postProcess (UnityEditor.Modules.BuildPostProcessArgs,UnityEditor.BuildProperties&)
    0x000001fe86a960b2 (Mono JIT Code) UnityEditor.PostprocessBuildPlayer:postprocess (UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,string,string,string,int,int,UnityEditor.BuildOptions,UnityEditor.RuntimeClassRegistry,UnityEditor.Build.Reporting.BuildReport)
    0x000001fe86a96690 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_int_int_object_object_object_int_int_int_object_object (object,intptr,intptr,intptr)
    0x00007ffeceb700e0 (mono-2.0-bdwgc) [mini-runtime.c:2849] mono_jit_runtime_invoke
    0x00007ffeceaf2ac2 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
    0x00007ffeceafbb1f (mono-2.0-bdwgc) [object.c:2968] mono_runtime_invoke
    0x00007ff762ec0754 (Unity) scripting_method_invoke
    0x00007ff762ebb851 (Unity) ScriptingInvocation::Invoke
    0x00007ff7649d65fa (Unity) CallMono
    0x00007ff7649dda58 (Unity) PostprocessPlayer
    0x00007ff7649d9030 (Unity) DoBuildPlayer_PostBuild
    0x00007ff7649d7780 (Unity) DoBuildPlayer
    0x00007ff7649cc2ca (Unity) BuildPlayer
    0x00007ff764348704 (Unity) BuildPipeline::BuildPlayerInternalNoCheck
    0x00007ff7642a9f5f (Unity) BuildPipeline_CUSTOM_BuildPlayerInternalNoCheck
    0x000001fe868ff63c (Mono JIT Code) (wrapper managed-to-native) UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck (string[],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,UnityEditor.BuildOptions,string[],bool)
    0x000001fe868c7733 (Mono JIT Code) UnityEditor.BuildPlayerWindow/DefaultBuildMethods:BuildPlayer (UnityEditor.BuildPlayerOptions)
    0x000001fe868be96b (Mono JIT Code) UnityEditor.BuildPlayerWindow:CallBuildMethods (bool,UnityEditor.BuildOptions)
    0x000001fe868bdf6b (Mono JIT Code) UnityEditor.BuildPlayerWindow:BuildPlayerAndRun (bool)
    0x000001fe868b90f3 (Mono JIT Code) UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()
    0x000001fe80737315 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr)
    0x00007ffeceb700e0 (mono-2.0-bdwgc) [mini-runtime.c:2849] mono_jit_runtime_invoke
    0x00007ffeceaf2ac2 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
    0x00007ffeceafbb1f (mono-2.0-bdwgc) [object.c:2968] mono_runtime_invoke
    0x00007ff762eb7f9e (Unity) CallStaticMonoMethod
    0x00007ff762eb7d51 (Unity) CallStaticMonoMethod
    0x00007ff7639c568f (Unity) BuildPlayerWithLastSettings
    0x00007ff7636efe2d (Unity) MenuController::ExecuteMenuItem
    0x00007ff7636ef57f (Unity) MenuController::ExecuteMainMenuItem
    0x00007ff76432f55e (Unity) EditorApplication_CUSTOM_ExecuteMenuItem
    0x000001fe868b8bde (Mono JIT Code) (wrapper managed-to-native) UnityEditor.EditorApplication:ExecuteMenuItem (string)
    0x000001fe868b8aab (Mono JIT Code) UnityEditor.ShortcutManagement.MenuItemEntryDiscoveryInfo:<.ctor>b__7_0 (UnityEditor.ShortcutManagement.ShortcutArguments)
    0x000001fe868b2041 (Mono JIT Code) UnityEditor.ShortcutManagement.Trigger:HandleKeyEvent (UnityEngine.Event,UnityEditor.ShortcutManagement.IContextManager)
    0x000001fe868aff53 (Mono JIT Code) UnityEditor.ShortcutManagement.ShortcutController:HandleKeyEvent (UnityEngine.Event)
    0x000001fe868afa93 (Mono JIT Code) UnityEditor.ShortcutManagement.ShortcutIntegration:EventHandler ()
    0x000001fe868af66e (Mono JIT Code) UnityEditor.EditorApplication:Internal_CallGlobalEventHandler ()
    0x000001fe80737315 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr)
    0x00007ffeceb700e0 (mono-2.0-bdwgc) [mini-runtime.c:2849] mono_jit_runtime_invoke
    0x00007ffeceaf2ac2 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
    0x00007ffeceafbb1f (mono-2.0-bdwgc) [object.c:2968] mono_runtime_invoke
    0x00007ff762ec0754 (Unity) scripting_method_invoke
    0x00007ff762ebb851 (Unity) ScriptingInvocation::Invoke
    0x00007ff762eb5615 (Unity) ScriptingInvocation::Invoke<void>
    0x00007ff76215d76b (Unity) Scripting::UnityEditor::EditorApplicationProxy::Internal_CallGlobalEventHandler
    0x00007ff7637c553a (Unity) CallGlobalInputEvent
    0x00007ff763d535da (Unity) GUIView::processEventMessages
    0x00007ff763d4d06d (Unity) GUIView::GUIViewWndProc
    0x00007fff25b41c4c (USER32) CallWindowProcW
    0x00007fff25b40ea6 (USER32) DispatchMessageW
    0x00007ff763d210c6 (Unity) MainMessageLoop
    0x00007ff763d253b1 (Unity) WinMain
    0x00007ff7653f326e (Unity) __scrt_common_main_seh
    0x00007fff25425550 (KERNEL32) BaseThreadInitThunk
    0x00007fff265a485b (ntdll) RtlUserThreadStart
     
  20. dptaf

    dptaf

    Joined:
    Sep 23, 2022
    Posts:
    14
    i'm on unity 2020.3.40f1 btw
     
  21. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Did this error happen with System.Net.Http.WebRequest.dll copied into the Unity project? Or was this happening when it was only references from a csc.rsp file?