我一直试图找到一些用于为.Net插件编写NSClient++的示例或文档。
有人能告诉我一个工作样例应用程序或一些文档吗?
我找到了CSharpSamplePlugin on GitHub的源代码。由于我不使用CMake,所以我创建了一个新的VS2013项目,并将CMake设置中引用的三个DLL添加到我的项目中(Google.ProtocolBuffers.dll、NSCP.Core.dll和NSCP.Protobuf.dll)。我在NSClient++安装dir中找到了DLL。
但是,SamplePlugin.cs中的代码似乎不适用于当前的DLL。我在线路上发现了一个错误:
response.AddLines(Plugin.QueryResponseMessage.Types.Response.Types.Line.CreateBuilder().SetMessage("Hello from C#").Build());..。说:
Error 2 'Plugin.QueryResponseMessage.Types.Response' does not contain a definition for 'Types' C:\vs_projects\NSClientHelpers\NsClientPlugin\SamplePlugin.cs 45 74 NsClientPlugin
Error 1 'Plugin.QueryResponseMessage.Types.Response.Builder' does not contain a definition for 'AddLines' and no extension method 'AddLines' accepting a first argument of type 'Plugin.QueryResponseMessage.Types.Response.Builder' could be found (are you missing a using directive or an assembly reference?) C:\vs_projects\NSClientHelpers\NsClientPlugin\SamplePlugin.cs 45 22 NsClientPlugin那么,有什么地方可以让我找到一个更新的样例插件或者如何制作NSClient++插件的例子呢?
在与此斗争了一段时间之后,我刚刚将命令重写为两个独立的可执行文件,但我感到很恼火,因为我无法让它工作起来;)
发布于 2015-07-03 08:24:42
我从NSClient on ServerFault的创建者那里得到了答案。简单地说,主分支中的代码与之前的版本不兼容。在签出发布标记中的示例代码并将得到的DLL放入“code /dotnet”文件夹后,我可以将插件添加到INI文件中.
[/modules]
DotnetPlugins = 1
[/modules/dotnet]
sample=CSharpSamplePlugin.dll..。看到这一切都适用于nscp test
...
D core Loading plugin: DotnetPlugin
L Webserver port is: 1234
...
check_dotnet
D Got command: check_dotnet
L cli OK: Hello from C#https://stackoverflow.com/questions/31176916
复制相似问题