acandylevey / NativeMessaging

C# Chome Native Messaging Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting memory out of exception issue while deserializing in Read method of Host.cs file

aggyasinghal opened this issue · comments

The buffer char array if pretty large and hence while converting it to string in the Jsonconverter parameter getting an exception out of memory.

What is the message you are trying to send across?

Any random string. For eg: a name

Can you give more light on this issue on how should I approach the method or what should be the steps to send the message?

I will need some further information here, how are you are serialising the json object from the browser?

Sure.
I'll explain the scenario which i want to work on.

I want to send a message to the chrome extension using the c# host application which you have mentioned and based on that message my extension will work and return me the result.
I want to know how can i make this work?
Can you pleas explain me the process with an example if possible?

I've raised an issue to #14 which I think once done will provide an end to end documentation on how it should all fit together.
I'm hoping to get some time to work on it before the end of the month

For now, can you tell the input for this method?

private static JObject Read()
{
//Log.LogMessage("Waiting for Data");

        Stream stdin = Console.OpenStandardInput();

        byte[] lengthBytes = new byte[4];
        stdin.Read(lengthBytes, 0, 4);

        char[] buffer = new char[BitConverter.ToInt32(lengthBytes, 0)];

        using (StreamReader reader = new StreamReader(stdin))
            if (reader.Peek() >= 0)
                reader.Read(buffer, 0, buffer.Length);
        string val = new string(buffer);

        return JsonConvert.DeserializeObject<JObject>(val);
    }

What value should I put in when the console opens?

It was kind of urgent. If u can put up the document in issue #14 ASAP then it would be a great help.
Thanks in advance.