I have a Windows service that I want to run with Mono on Linux. I can run it as a service using mono-service, and this works fine.
I also want to mkbundle the application to ease deployment for end-users, so they don't need to mess around installing Mono themselves.
What is the recommended way to run the resulting native binaries as a service on Linux, while still handling the OnStart and OnStop events?
mkbundle produces native code, so you can run the way you used to run the executable on the original platform.
It will only be an executable you might have to add it as service on linux yourself after creating an init.d script.
had to add it as an answer, as i can't add comments
Related
I currently have a windows service that needs to run in the background while a main application I have written handles UI and other tasks. I install and maintain the GUI application using ClickOnce Deployment and would like to find a way to bundle my Windows Service in as well.
They are in separate projects at the moment since I was still learning how to use the Windows Service.
My question is, is it possible given MyService.exe that I install and start MyService.exe from MyApp.exe? I can assume that I have access to InstallUtil.exe and could write a script to install and run it manually, but I would like a cleaner solution if there is one.
The only resources I've found all seem to assume I want to have the Service install itself, which is not the case.
In general, ClickOnce can't be used to install services. There is typically a lack of permissions, but also the location is incorrect, etc. For details, see MSDN on Choosing Between ClickOnce and Windows Installer for more details.
If you want to install a service, you should do a traditional installation.
My c# apps developed on windows run nicely on ubuntu, but the ones having dll files don't. Is there a work around or i have to recompile the code on linux
Interop.SpeechLib.dll is part of Microsoft's Speech API (SAPI).
That doesn't exist on Linux, so you'll have to find an alternative API to call there.
You won't necessarily have to maintain two separate code bases, though. You could execute a run-time check for the host platform/environment, and call the appropriate API for that environment.
I have a few console apps that I want to run on a dedicated box. However, I have no interest in purchasing a windows license.
Is there anything special I have to do after compiling the code to run on linux mint?
Normally, you'd install mono
http://community.linuxmint.com/software/view/mono-runtime
http://community.linuxmint.com/software/view/mono-complete
The most popular package for developers seems to be
http://community.linuxmint.com/software/view/monodevelop
With existing console applications, there will be no need to recompile (.NET is platform indepent, remember?). However, there could be slight incompatibilities to missing support for very specific Microsoft Class libraries (think of WPF, till recently Message Queues, some Winforms Stuff and obvious Interop (P/Invokes of native libraries).
Use the Moma tool to scan for such incompatibilities, and you'll get a nice overview of things that might cause a problem.
Just compile your code using the Mono compiler and you should be good, if it's a simple console app.
Assuming you have Mono installed on the Linux box and you don't use anything MS-specific, then no, you don't have to do anything special. Just compile the .exe, copy it to the linux box and run it using mono the_app.exe.
I am writing a portable service/daemon using .NET 3.5, my windows service is running, but I was wondering about the mono port...
Mono-service is what I am looking for if I understand correctly. How exactly does this work though? I assume I need mono compatible code throughout my service, right? For example, I am using SQLite. Is it correct that in order to use this with mono I should refactor my code to use mono namespaces etc, such as Mono.Data.SQLite? May I still use Settings.settings?
Also, I've read that daemons don't implement onStart/Stop methods, so do I need to change my code to run under mono/linux? i.e. is it ok to have these methods in my code, and ok to run ServiceBase.Run()? Does Mono-service accommodate these?
You should create your programs from the beginning for use with Windows and Linux.
You need Visual Studio with Mono Tools or the free MonoDevelop-IDE to create a Mono-Application. MonoDevelop can import your Visual Studio Project. This IDE helps you to get the right namespaces.
Use Mono-Service to run your Assembly as daemon. Linux Daemons are using Signals to communicate with the System. Please read the documentation.
We already had a similar question, so please read this to see, how to process Unix-Signals.
We are building an application on .net, And it is an Image Viewer application uses .net 3.5.
And this application will be on a CD along with other images.
My Question is, is it possible to Auto Run this application when you insert a CD on a machine which DOESN'T Contain .NET Frame Work.
Or any other ways of building the application which runs from the CD.
Autorun is a feature of Windows. It does not have anything to do with .NET really. You can use it by placing apropriate files in the root of your CD.
See: http://en.wikipedia.org/wiki/AutoRun
In order to execute a .NET app WITHOUT .NET framework installed, point the Autorun.inf to an installer of you application, which would be deployed on the CD as well.
The application will fail to run directly when it cannot find the libraries it need.
What you can do is to create a non-.NET dependent bootstrapper, include the framework installer.
So when the CD auto run, run the bootstrapper, the bootstrapper will run the installer. Once installed, run the application.
No, you can't run .NET applications on a computer without the .NET Framework installed. That's a hard rule, and a pretty intuitive one, it seems to me. Somehow, this question still gets asked a lot.
But Auto Run has nothing to do with the .NET Framework. It's a feature provided by the Windows operating system designed to run your setup/installation program directly from the inserted installation medium without requiring any kind of user interaction.
So what you should be doing is creating a setup program for your .NET application. You can do this from within Visual Studio: just create a Setup Project instead of a Windows Forms Application. The setup program will take care of detecting whether or not the computer has the appropriate version of the .NET Framework installed, and installing it if necessary along with the application. The setup bootstrapper will be able to run without the .NET Framework installed, so you can create an autorun.inf file that simply specifies setup.exe as the application to be launched automatically.
I've used mono to do this a few times, not with the static linking as mentioned in the other answer, but by including the mono distribution on the cd (or a subset of it). Mono doesn't seem to do much in the way of modifying registry, system32, etc. So you can do an xcopy deployment of if, or CD deployment in this case. You'll end up running mono.exe
I think Mono supports some form of static linking that doesn't require installation. But I never tried it myself.