How to run c# app having dll files on linux - c#

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.

Related

Access denied error for Process.Start inside .NET Standard library referenced in UWP

In my VS2017 solution, I created a UWP and .NET Standard Library 2.0.3 projects. Referenced Library project from UWP. Library project is using a System.Diagnostics.Process to start a process. In debug mode, I get access denied error at line Process.Start(...) of the code inside Library project.
I thought the purpose of new .NET Standard Library project was to support various platforms (.NET, .NET Core, UWP etc) uniformly. But I guess, the sandbox nature of UWP apps is probably not allowing me to run Process.Start(...) albeit the process is running inside Library project. Question: What I may be missing and/or how can we resolve the above issue?
You cannot launch process directly from UWP, but there are some alternative ways to do that. The first one is using FullTrustProcessLauncher, if you need some example, check this post series. Another way is using a WPF or WinForms application to host UWP Controls with the Xaml Islands where there aren't restrictions to call any .NET APIs, but remember, through this way, your app will work only on Desktop devices.
According to this answer, you can't use Process.Start in a UWP app. There are some alternatives for launching other apps, but you can't execute arbitrary .exe or other processes.

mono-service for mkbundle'd apps

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

How to run a driver (.sys file) in Windows using C#

I'm developing a Windows Application using C#. I wanted to run a .sys file (driver basically) at the backEnd as my Code makes use of certain functions to implement the output.
How can i write a code in C# ? If the .sys file is placed in "Bin" folder, it just does not run as I guess it can be made to run as a service.
Consider the name - "someDriver.sys" (I'm using Win7 OS here)
Can I run this .sys file as Service in Kernel mode?
My application is a very simple one and does not have installer (I do not want to have it too). Can you pl help how I can tackle this situation where I need the presence of .sys file for my functions to work.
Have you tried to see how it's done in this article How to install driver dynamically or install driver as a service for Windows
You must adapt calls using interop.
Use this tools to help you in Interop definition : PInvoke Interop Assistant
You can use the code from this answer and just change SERVICE_WIN32_OWN_PROCESS to SERVICE_KERNEL_DRIVER (0x00000001). Then you can just do
ServiceInsatller.InstallAndStart("yourServiceName", "Some Description", "C:\path\to\driver.sys");
This works for me.

.NET Service to Linux Daemon

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.

how to run a winform Exe in normal Pc not having .net frame work installed

I developed a winform application using C# in visual studio 2008. Now i want to run the exe on another PC which doesn't have .net framework or Visual Studio. I am sending the application using Zip via email. The second PC downloads that application and extracts into a normal folder and then it executes the exe file.
But i am getting the exception that .net frame work v 2.0 must be installed.
Can you please tell me how to run that exe without .net frame work installed?
(Amended for #Merhdad's sanity :-))
The short answer: You can. You shouldn't.
The long answer: You could technically create your own unmanaged bootstrapper that goes and download the .NET client profile redist and silently installs it using the MSI APIs, and then loads the CLR and hosts it in the process in order to execute the managed code, after which it silently uninstalls the .NET Framework from the machine.
The Disclaimer: I know few people that could pull that off. They would be the first to tell you not to do it.
The alternative hack answer: You can also use one of the tools #Mehrdad mentioned. i can't comment whether they work or not. However, you should be aware that this leaves your app linked to a specific snapshot of the .Net framework code, and for every security update you need to take, yuo have to relink and release an update of your application as well.
The alternative open source answer: You could ensure your WinForms app builds and runs on Mono, and deploy Mono side-by-side with the app. I've heard it supports that scenario.
The alternative IT answer: You could create a VM appliance with stripped down Window image that has .Net and your app only, and ship it as a single executable.
The right answer: Create an installer for your app that installs the .NET Framework for your customers.
Yes! You can do this with a variety of programs, and Spoon seems to be among the most up-to-date ones.
(Of course, this doesn't mean that you should, just that you can.)
This cannot be done. You must have the .NET Framework in order to run the application.
I solved the problem.I added a package in visual studio.I added Setup and deployment as a new project to my solution.later i added exe to that package.so if client machine runs the setup it'l create exe and can run the application successfully.
yeah,you can do that by converting your whole application to an installer.just check it out, it will helps u a lot
http://www.youtube.com/watch?v=PCnfGUT-K-4

Categories

Resources