且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Chrome扩展程序本地消息传递出现错误:“未找到指定的本地消息传递主机”。

更新时间:2023-08-21 14:23:16

注册表项应该是 HKEY_LOCAL_MACHINE \SOFTWARE\Google\\ \\ Chrome \NativeMessagingHosts\com.my_company.my_application ,它是(默认)值应该是 D:\\ \\ testC \debug\manifest.json



从您的描述中可以看出,您正在添加名称 com.my_company.my_application 下的键 HKEY_LOCAL_MACHINE \SOFTWARE\Google\Chrome\NativeMessagingHosts


My platform OS is win 7. I started to write extension and try to communicate with C++ app. Here is manifest of my app: (xxx is my extension id)

{
  "name": "com.google.chrome.testc",
  "path": "D:\\testC\\debug\\testC.exe",
  "description": "My Application",
  "type": "stdio",
  "allowed_origins": [
  "chrome-extension://xxx/"
  ]
}

And I also add registry key at: HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts: "com.google.chrome.testc: D:\testC\debug\manifest.json"

But when extension called "chrome.runtime.sendNativeMessage('com.google.chrome.testc', ...)", it always report "Specified native messaging host not found.".

What step I missed? or something wrong above? Thanks.

The registry key should be HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.my_company.my_application, and it's (Default) value should be D:\testC\debug\manifest.json.

From your description it seems that you are instead adding a string value with name com.my_company.my_application under the key HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts