I followed the native messaging documentation to the best of my abilities, but can't seem to get my native .NET application to even start running on Windows. While looking for additional information, I noticed some things are undocumented and unclear.
First off, the documentation does not mention the requirement of adding the "nativeMessaging" permission. After changing this I got a bit further; Chrome actually mentions "New background app added" in a balloon popup now.
However, the following code keeps disconnecting immediately, regardless of some of the things I tried.
var port = chrome.runtime.connectNative( ... );
port.onDisconnect.addListener(
function()
{
console.log( "Disconnected" );
} );
Based on my attempts to debug this thing, I have several questions:
There seem to be too many variables right now for me to debug this, and don't immediately see how I can verify whether or not my registry value at least is set up correctly.
I got it working and figured I'd try breaking my solution again in as many different ways possible to answer my originally posed questions. However, I do not remember/know why it didn't work before. In fact, it only started working after I gave up; I had to restart Chrome since an update was installed (34.0.1847.116 m), after which all of a sudden my native application showed up since the plugin I was working on was still enabled.
That aside, the following is a report on what does and does not work by changing some things and seeing whether the native application is still launched.
1. On Windows, when does Chrome try to load the manifests from NativeMessagingHosts
in the registry?
Whenever you click "Reload" on the extension you are developing in "chrome://extensions/", the native host will be loaded again from the registry. In other words, it suffices to click reload to verify whether your manifest files and registry are set up correctly.
2. The absolute path in the registry, how should it be formatted?
This is an example of a valid registry value:
C:\Users\Bleh\Some\Path Even With Spaces\No\Problem\someManifestFile.json
3. Is there any way to get more information on what is going wrong?
Well, you might be able to look at Chromium's source code to determine exactly what happens, but other than that I don't see any more extensive feedback you can get from the offered APIs.
4. How should the path in the manifest be formatted? Example from the documentation, which seems to be correct:
"path": "C:\\Program Files\\My Application\\chrome_native_messaging_host.exe"
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