开发者

Run C# .exe with crontab or daemon?

开发者 https://www.devze.com 2023-02-15 09:07 出处:网络
I was wondering if i can run a dll (c#) with crontab ? The dll is compile with mono. thx :) -- EDIT -- Well it can be a .exe. I was looking at daemons on mac and linux, do you think I ca开发者_运维

I was wondering if i can run a dll (c#) with crontab ? The dll is compile with mono.

thx :)

-- EDIT --

Well it can be a .exe. I was looking at daemons on mac and linux, do you think I ca开发者_运维知识库n run .exe as a daemon.


Why not write a mono-based exe that takes the DLL path and entry point method as parameters? The exe would then use reflection to load the DLL and execute the specified method. (You could opt for convention-over-configuration by specifying something like a DllMain method in your DLL which the exe would know to call automatically. Then just one parameter would be required and the intent of your code more obvious.)

Implementing such an applet would give you a utility similar to RunDll in Windows and allow you to run mono DLLs from cron.


You may want to check out the latest mono release and C# Shell (although I would personally make an exe that called the functions you want from the DLL).

http://www.mono-project.com/CsharpRepl

"On startup the csharp shell will load any C# script files and pre-compiled libraries (ending with .dll) that are located in the ~/.config/csharp directory (on Windows this is the value of Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData)).

The assemblies are loaded first, and then the scripts are executed. This allows your scripts to depend on the code defined in the assemblies.

C# script files are merely files that contains statements and expressions, they can not contain full class definitions, those should be stored and precompiled in DLL files. "

Then you can do things like:

 csharp> using System;   
 csharp> Console.WriteLine ("hello");    
 hello   
 csharp>   
0

精彩评论

暂无评论...
验证码 换一张
取 消