IPC not working with empty string
Posted: Tue Oct 11, 2016 3:50 pm
Hello.
I have to send data from the renderer process to the browser process.
I use CefBrowser.SendProcessMessage for this.
I send an int and a string.
The problem is, that in some cases the string is empty.
So the code is something like this:
When receiving this message in the browser process I can use Console.WriteLine to output the arguments with message.Arguments.GetInt(0) and message.Arguments.GetString(1). This works in the Console.WriteLine, it outputs 1337 for the int and nothing for the string.
BUT I somehow can't use message.Arguments.GetString(1).GetType()
This gives me a null reference exception. If I send any other string it works, but it doesn't work with an empty string like "".
Why is that? Why can't I use Get.Type() on that?
It must have something todo with how the inter process communication actually works.
Take a look at this simple code:
This doesn't get me a null reference exception, so somehow the empty string I send via IPC doesn't arrive as such.
I have to send data from the renderer process to the browser process.
I use CefBrowser.SendProcessMessage for this.
I send an int and a string.
The problem is, that in some cases the string is empty.
So the code is something like this:
- Code: Select all
CefProcessMessage msg = CefProcessMessage.Create("testMessage");
var args = msg.Arguments;
args.SetInt(0, 1337);
args.SetString(1, "");
IPC.Browser.SendProcessMessage(CefProcessId.Browser, msg);
When receiving this message in the browser process I can use Console.WriteLine to output the arguments with message.Arguments.GetInt(0) and message.Arguments.GetString(1). This works in the Console.WriteLine, it outputs 1337 for the int and nothing for the string.
BUT I somehow can't use message.Arguments.GetString(1).GetType()
This gives me a null reference exception. If I send any other string it works, but it doesn't work with an empty string like "".
Why is that? Why can't I use Get.Type() on that?
It must have something todo with how the inter process communication actually works.
Take a look at this simple code:
- Code: Select all
string str = "";
Console.WriteLine("StrType: " + str.GetType());
This doesn't get me a null reference exception, so somehow the empty string I send via IPC doesn't arrive as such.