LavaGang / MelonLoader

The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono
https://discord.gg/2Wn3N2P
Apache License 2.0
2.22k stars 458 forks source link

[Bug]: WebProxy Issues #320

Open HerpDerpinstine opened 1 year ago

HerpDerpinstine commented 1 year ago

Can be fixed by Harmony patching: https://github.com/mono/mono/blob/901ca2bf6d8b8bbc6f8f55a751b2e750eea2b291/mcs/class/System/ReferenceSources/AutoWebProxyScriptEngine.cs#L126

Exception while Contacting RemoteAPI Host (https://api.melonloader.com/api/v1/game/bloonstd6): System.Net.WebException: An exception occurred during a WebClient request. ---> System.NullReferenceException: Object reference not set to an instance of an object

  at System.Net.AutoWebProxyScriptEngine.InitializeRegistryGlobalProxy () [0x0005b] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.AutoWebProxyScriptEngine.GetWebProxyData () [0x00007] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.WebProxy.UnsafeUpdateFromRegistry () [0x0001a] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.WebProxy..ctor (System.Boolean enableAutoproxy) [0x0000d] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.WebProxy.CreateDefaultProxy () [0x00012] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.Configuration.DefaultProxySectionInternal.GetSystemWebProxy () [0x00000] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.Configuration.DefaultProxySectionInternal.GetDefaultProxy_UsingOldMonoCode () [0x00036] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.Configuration.DefaultProxySectionInternal.GetSection () [0x00015] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.WebRequest.get_InternalDefaultWebProxy () [0x00022] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.HttpWebRequest..ctor (System.Uri uri) [0x0008d] in <d2957de1c3fd4781a43d89572183136c>:0 

  at (wrapper remoting-invoke-with-check) System.Net.HttpWebRequest..ctor(System.Uri)

  at System.Net.HttpRequestCreator.Create (System.Uri uri) [0x00000] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.WebRequest.Create (System.Uri requestUri, System.Boolean useUriBase) [0x00091] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.WebRequest.Create (System.Uri requestUri) [0x00014] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.WebClient.GetWebRequest (System.Uri address) [0x00000] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.WebClient.DownloadDataInternal (System.Uri address, System.Net.WebRequest& request) [0x00013] in <d2957de1c3fd4781a43d89572183136c>:0 

   --- End of inner exception stack trace ---

  at System.Net.WebClient.DownloadDataInternal (System.Uri address, System.Net.WebRequest& request) [0x00072] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.WebClient.DownloadString (System.Uri address) [0x00020] in <d2957de1c3fd4781a43d89572183136c>:0 

  at System.Net.WebClient.DownloadString (System.String address) [0x00016] in <d2957de1c3fd4781a43d89572183136c>:0 

  at (wrapper remoting-invoke-with-check) System.Net.WebClient.DownloadString(string)

  at MelonLoader.Il2CppAssemblyGenerator.RemoteAPI.ContactHosts () [0x0005f] in <c5740a4bf8844aa0bba791293b614f53>:0 
SamboyCoding commented 1 year ago

This should be, at least for the assembly generator case, solved with 0.6.0, as IL2CPP games now run under CoreCLR which has no such issues with WebClient. Might want to keep this open for anyone who wants to use HTTP(s) in their own mods on mono games