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:
- On Windows, when does Chrome try to load the manifests from NativeMessagingHosts in the registry? In other words, should I restart Chrome when I change the value, or is it sufficient to reload the extension in "chrome://extensions/"?
- The absolute path in the registry, how should it be formatted? E.g. I've seen people stating only "\\\\" slashes as path separators work. Does it need surrounding quotes?
- Is there any way to get more information on what is going wrong? For testing purposes, I renamed the registry key to see whether I would get a different error (assuming since it can't load it would notify me of that). Instead "onDisconnect" still seems to be called.
- Similar to the path in the registry, how should the relative path pointing to the native application in the native application manifest file which the registry value points to be formatted? (there is an example of this in the documentation, but just to be sure what works and what doesn't ...)
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.