本地消息在Windows .NET应用程序 [英] Native messaging to .NET application on Windows

查看:102
本文介绍了本地消息在Windows .NET应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟着href="https://developer.chrome.com/extensions/messaging#native-messaging" rel="nofollow">本地消息文档尽我的能力

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.

首先,文件没有提到添加的nativeMessaging的权限的要求。改变这一点后我有点进一步; Chrome浏览器居然提到了新的后台程序增加了在气球弹出了。

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.

但是,下面的code不停立即断开,不管一些事情我试过了。

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:

  1. 在Windows上,什么时候Chrome浏览器尝试加载从NativeMessagingHosts的体现在注册表中?换句话说,我应该重新启动浏览器时,我改变的价值,或者是足以重新加载扩展?铬://扩展/
  2. 在注册表中的绝对路径,究竟应该如何格式化?例如:我见过的人只能说明\\\\的斜杠作为路径分隔符的工作。是否需要周围的报价?
  3. 有没有什么办法让上了什么错误信息?为了进行测试,我改名的注册表键,看看我是否会得到不同的错误(假设,因为它无法加载它会通知我的那个)。相反的onDisconnect的似乎仍然被调用。
  4. 类似的注册表路径,应该如何指向本机应用程序中的本机应用程序清单文件中的相对路径,注册表值指向被格式化? (有一个这样的例子在文档,但只是要确定什么作品,什么不...)
  1. 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/"?
  2. 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?
  3. 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.
  4. 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.

推荐答案

我得到它的工作,并想我会再次尝试打破我的解决方案,可以回答许多不同的方式我最初提出的问题。但是,我不记得/知道为什么它没有工作之前。事实上,这只是开始后,我放弃了工作;我不得不重新启动浏览器,因为更新安装(34.0.1847.116米),之后突然我的本机应用程序出现了,因为插件我工作仍然有效。

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。在Windows上,什么时候Chrome浏览器尝试加载从 NativeMessagingHosts 的体现在注册表中?

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。在注册表中的绝对路径,究竟应该如何格式化?

这是一个有效的注册表值的示例:

This is an example of a valid registry value:

C:\ Users \用户的Bleh \有些\路径,即使   空间\无\问题\ someManifestFile.json

C:\Users\Bleh\Some\Path Even With Spaces\No\Problem\someManifestFile.json

  • 没有的周围的引号。
  • 在使用单反斜线工作,因为这样做前锋斜线,斜线或者甚至是无限的。 :o如。C:\有些\\\很怪\路径
  • 。JSON的扩展需要。
  • 它必须是绝对的。

  • Without surrounding quotes.
  • Using single backslashes works, as do forwards slashes, or even an infinite amount of slashes. :O E.g. "C:\Some\\\Very Weird\Path".
  • ".json" extension is required.
  • It needs to be absolute.
  • 3。有没有什么办法让上了什么错误信息?

    那么,你也许能看到Chromium的源$ C ​​$ C,以确定到底发生了什么,但除此之外,我没有看到任何更广泛的反馈,你可以从所提供的API获得。

    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。应该如何在清单的路径被格式化?

    路径:C:\\ Program Files文件\\我   应用\\ chrome_native_messaging_host.exe

    "path": "C:\\Program Files\\My Application\\chrome_native_messaging_host.exe"

    • 在两个反斜线需要作为分隔符。
    • 路径的可以的是相对的。

    • Two backslashes are needed as separators.
    • The path can be relative.
    • 这篇关于本地消息在Windows .NET应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆