Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aggyasinghal opened this issue May 5, 2021 · 9 comments

Comments

@aggyasinghal
Copy link

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

@acandylevey
Copy link
Owner

What is the message you are trying to send across?

@aggyasinghal
Copy link
Author

Any random string. For eg: a name

@aggyasinghal
Copy link
Author

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?

@acandylevey
Copy link
Owner

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

@aggyasinghal
Copy link
Author

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?

@acandylevey
Copy link
Owner

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

@aggyasinghal
Copy link
Author

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);
    }

@aggyasinghal
Copy link
Author

What value should I put in when the console opens?

@aggyasinghal
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants