我刚刚从.net开发转移到LINUX MONO开发......我以前对linux开发人员有很多经验..
我要求在单声道c#中创建后台服务(如Windows服务)..是否可能..
是否可以从单声道c#访问LINUX本机API.(比如来自win c#的winAPI调用)..
嗨,我正在尝试使用mono-service2从visual studio运行一个股票Windows服务项目.我正在使用mono 2.0和编译器在debian上运行它.
gmcs *.cs -pkg:dotnet
Run Code Online (Sandbox Code Playgroud)
我尝试从这开始(我尝试使用-d设置为dir与app和-n,-m设置)
mono-service2 -l:service.lock --debug Program.exe
Run Code Online (Sandbox Code Playgroud)
唯一的代码更改是添加用于测试的writelines
Service1.cs
using System;
using System.ServiceProcess;
namespace spikes
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
Console.WriteLine("starting...");
}
protected override void OnStop()
{
Console.WriteLine("stopping....");
}
}
}
Run Code Online (Sandbox Code Playgroud)
结果是这个错误
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for Mono.Unix.Native.Syscall ---> System.DllNotFoundException: libMonoPosixHelper.so
at (wrapper managed-to-native) Mono.Unix.Native.Syscall:_L_ctermid ()
at Mono.Unix.Native.Syscall..cctor () [0x00000]
--- End of inner exception …Run Code Online (Sandbox Code Playgroud) 是否可以在PS3上创建应用程序(而不是游戏)?我知道有很多方法可以安装Linux以及所有这些,但我希望你可以从网上下载并运行.我希望该应用程序像服务器/守护程序一样运行,并能够访问网络.
我似乎无法找到一种方法让一个C#服务作为debian中的"服务"运行.我究竟做错了什么?
我跟着这个帖子从MSDN创建一个样本窗口服务:http://msdn.microsoft.com/en-us/library/zt39148a(v=vs.80).aspx
我可以在我的Windows机器上运行该服务,启动和停止服务,并看到它写入MyNewLog.
然后我将它(.exe文件)复制到我的debian机器并尝试使用(作为root)mono-service MyNewService.exe运行它
Syslog告诉我,服务已经开始了!
我没有错误,我在系统中看不到任何新创建的日志文件.我究竟做错了什么?
如果有帮助,这里是代码:Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
namespace MyNewService
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[]
{
new MyNewService()
};
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
}
}
Run Code Online (Sandbox Code Playgroud)
Service.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
namespace MyNewService
{
public partial class MyNewService …Run Code Online (Sandbox Code Playgroud)