Can I communicate to Google Chrome in C#?
For writing a chrome plugin for example.
What I have done to address is use Simple Message Host
, it will trigger an executable on the local machine that you code in c#, sending stdin
messages and listening to stdout
messages so you can build this host to use as a bridge, but like I said, it needs to be on your local network
at least, and you have to do some editing in the windows registry
, so it has its limitations.
But for the system I am working with, this solution worked perfectly because I have a controlled environment that I can set up all these prerequisites.
So, just to clarify, what I did here is:
Create a chrome extension with background.js
opening up the listener to the website's javascript.
Add a registry in windows registry
pointing to the path of the executable.
Create the executable in C# doing all your logic.
Send a response from the executable to the extension and then back to the website.
There are several guides on how to do this, so I won't detail these steps here so I don't replicate it.
But for the moment, it is the best way to do what you want, if you have control of your environment that is.
So, if your plugin (extension or chrome app) will work on a controlled environment, this is the way to go, otherwise, I would consider something related to ClickOnce
perhaps or WebAssembly
but that's not fully released yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With