titanium-web-proxy icon indicating copy to clipboard operation
titanium-web-proxy copied to clipboard

SystemProxyManager.openInternetSettingsKey null reference

Open kakins opened this issue 5 years ago • 8 comments

Trying to use this in a Unity3d project. I'm not sure if this has something to do with the Unity itself, perhaps because it is running Mono? I get the following error when using some of the example code:

NullReferenceException: Object reference not set to an instance of an object
Titanium.Web.Proxy.Helpers.SystemProxyManager.openInternetSettingsKey () (at <0ffc67c1d5eb437194b5d20a4fd33c88>:0)
Titanium.Web.Proxy.Helpers.SystemProxyManager.GetProxyInfoFromRegistry () (at <0ffc67c1d5eb437194b5d20a4fd33c88>:0)
Titanium.Web.Proxy.ProxyServer.Start () (at <0ffc67c1d5eb437194b5d20a4fd33c88>:0)

It appears the null reference is in the body of openInternetSettingsKey.

However, when I try to run the same code in my Immediate Window in Visual Studio while debugging, I do not get a null reference:

Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true)

"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"
    base: "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"
    Handle: {Microsoft.Win32.SafeHandles.SafeRegistryHandle}
    Name: "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"
    SubKeyCount: 10
    ValueCount: 15
    View: Default

kakins avatar Jan 22 '20 02:01 kakins

Yes, on Unity it seems to be unsuppoprted... I'll add a check for that.

honfika avatar Jan 22 '20 07:01 honfika

The Registry.CurrentUser is null, right? Could you please check it?

honfika avatar Jan 22 '20 07:01 honfika

Well, I assuming it is null when code path reaches openInternetSettingsKey. However, when I check Registry.CurrentUser before starting the proxy server, it is not null. There's no way for me to check the state of Registry.CurrentUser once the execution reaches openInternetSettingsKey, I can't debug into that method.

kakins avatar Jan 22 '20 15:01 kakins

I added a null check. Please try the latest beta packade... Do you still receive the nullreference exception in TPW openInternetSSettingsKey?

honfika avatar Jan 22 '20 17:01 honfika

That seemed to do it. The proxy starts and says it's listening, however none of the handlers are hit. For instance, just using the default setup from the readme, and navigating to something like google.com, no traffic seems to be intercepted. That may be a separate issue, though.

kakins avatar Jan 23 '20 00:01 kakins

From where do you send the requests? Are you sure that you corretly set the proxy URL in your browser (if it is a browser)?

honfika avatar Jan 23 '20 08:01 honfika

I was sending the requests just from a regular web browser. I didn't know there was a specific proxy URL I needed to use.

kakins avatar Feb 04 '20 22:02 kakins

You should set the proxy address in your browser. Is everything ok after you set the proxy?

honfika avatar Feb 04 '20 22:02 honfika

Closing this guy because I'm no longer working with this

kakins avatar Jan 12 '23 15:01 kakins