Raspberry Pi 3 Mono C# Bluez - c#

Using Raspberry Pi 3 and it's built-in BLE chip I was able to install a Bluez nodejs example app to make my Raspi3 a BLE Peripheral, and I was able to read and write to the Gatt and echo information to my BLE Central Client.
However, now that I am trying to replace the nodejs BLE Perhipheral solution on my Raspi3 to use Mono.BlueZ, and dbus-sharp mono libraries to make a mono app that would make my Raspi3 a BLE Perhipheral.
Immediately, I am running into issues compiling
I am compiling in VS 2017 RC as a 3.5 project.
dbus-sharp project I am trying to compile:
https://github.com/brookpatten/dbus-sharp
Supporting Mono Bluez file that I will eventually use:
https://github.com/brookpatten/Mono.BlueZ
Is there something that I need to do to actually compile the project?
Is there any additional documentation or examples of how to get this compiled?

I'm also trying to work with this project.
I managed to build and debug it like this (on Debian 8):
I installed the latest version of Mono (5.0) and could build the project by just typing msbuild in the project root. It also works from within VS Code and I can also debug the project after creating launch.json and tasks.json files.
However, when I debug Mono.BlueZ.Console, it hangs right away on this line:
var manager = GetObject (Service, ObjectPath.Root);

Related

Run a windows form application on Raspberry Pi made using C#

I neeed to run a windows form application on Raspberry Pi made using C#.
I have tried the option of installing a windows os and running the exe application . It does work but the issue is that it is slow and takes a lot of time for the application to work.
Is there any possibility to run the exe directly on raspbian ?
You can't natively run winform applications under Linux, but maybe you could try using Wine or one of the other compatibility tools for Linux.
If you are the author of the application you could port your app to GTK# which is a desktop GUI Toolkit for Linux with C#
What I'm using right now:
You can execute Windows Forms Applications written in the .NET Framework (newest 4.8, no longer continued) with mono.
On the raspberry pi, if I recall correctly, you can "sudo apt install mono-complete" and then run it via the terminal: "mono YourApp.exe"
As I said, it sadly only works with .NET Framework Applications (or maybe on rare occasions with .NET 6.0 too, hasn't worked for mine though), you may be able to change that in Visual Studio though (or new project and then copy/paste the code).
The only downside is that you are then using an older version of C#, meaning some things may be different from what you are used to.

How do I compile a C# application on a Mac in Visual Studio?

Basically, my school only has Mac computers, however they're telling me to learn C# and to do so using Visual Studio. However, the school program is fairly new and the projects are self-guided. I've been coding in C# using Visual Studio and it's been working so far - it's run successfully and everything. However, I can't seem to find a way to export or publish my code into a standalone application. I've tried using WineBottler to convert the .exe into a .dmg, but I can't seem to make it work.
How should I do this? Moving to Windows or another IDE/compiler isn't an option. I've currently been creating my projects in a Console App, but I could change that if necessary.
After quite a bit of experimentation and research, I've found that while you can publish a .NET Core Console App within Visual Studio for Mac, the feature is not supported within the GUI of the program (for whatever reason).
In order to publish, you have to Control-Click on the solution in the Solution Explorer and open the project in the command line by clicking Tools > Open In Terminal.
Once there, type in the command:
dotnet publish -c Release --framework netcoreapp2.1 --runtime osx-x64
This will create a self-contained program for 64-bit mac os on the v2.1 .NET Core framework. The runtime can be changed for different operating systems and the version number for netcoreapp can be changed based on which version you're using and what is compatible with any plugins for your program.
The final product will be found in yourprojectfolder/yourprojectname/bin/Release/netcoreapp2.1/osx-x64/publish
You should have no issues creating and compiling .NET CORE console apps using a Mac. These apps will have limited .NET functionality, do not have .exe files, and are platform agnostic. Here is a quick guide you can reference to decide if .NET CORE is the right option for you.
If you are trying to create WinForm apps or something similar, you cannot do this on a Mac. There are "work arounds" using Wine or other tools, but my experience with those options has been suboptimal at best. If you need to create apps like this, then your best option is to program on a Windows machine. Perhaps ask your school to enable bootcamp and install Windows 10 OS on one of the Mac machines.
You can generate exe using the terminal if you are on OSX. You can follow this post
It requires :
Visual Studio For Mac
A .cs file
Few lines in terminal

monodevelop - working debug but not working release

I have developed a project with VS on Windows 10. Right now on Linux mint i am debugging the project with MonoDevelop and it runs just fine.
Let me show you:
However when i make a build and i go to the Release folder and then i try from the terminal to launch the program i have a problem. Let me show you first the files i have build:
Then i go to the directory with my terminal and i run:
chmod +x ./WorldServer.exe then i run ./WorldServer.exe
and i receive the following error:
I know that this is .exe file and maybe i have to build a different type of file. But i am not really sure what setting should i apply in my project to make a working build for linux.
As far as i know linux is using .so as extension for it's libraries. However it is generating .dll files. Can i change that? Can i somehow make my project to be "buildable" in the two OS Linux and Windows ?
The exception tells us, you need System.Management in your project. It isn't there.
Why?
Because Mono, according to there Road-map, doesn't support this:
The following do not map to operating systems other than Windows, and
we are unlikely to spend time to support them even on Windows:
System.Management
How?
System.Management is a library that only works on Windows. The MySQL connector driver has started to depend on this library and tries to load it per reflection.
I'm not into this whole MySql Progess but there is an open bug for it. Also there is a comment which says:
The last working version of the MySQL .NET Driver is 6.4.6
I hope this helps you.

MonoGame porting to linux

I have developed a game on Windows 7 (64bit) in Visual Studio 2015 with the language C# and the MonoGame framework. The game works fine on Windows, but I also wanted to make the game to be playable on Linux. Therefore I installed VirtualBox with Ubuntu 15.10 (64bit) on my Windows PC, to test if I can make my game running on Ubuntu.
After trying to compile the game in different ways with no solution in sight, I came to the conclusion to ask a few questions here about deploying MonoGame to Linux:
Is it possible to compile a MonoGame game in VisualStudio 2015 on Windows for Linux in a...
1.1. MonoGame Linux Project?
1.2. MonoGame Windows OpenGL Project?
1.3. MonoGame Windows Project? (which my game currently is)
If [1.] what are the requirements and what programs need to be installed on Linux to run this [1.x] build?
Is it possible (and recommended) to compile the game in MonoDevelop on a virtual Ubuntu machine?
Is it even possible to run a MonoGame game on a virtual Ubuntu machine?
What is the proper executable file extension for a game on Linux? (Because Linux Project on Windows is only building a .exe)
I have almost no experience with Linux, so I hope someone can answer me these questions, maybe someone who has experience with porting a MonoGame game to linux.
Thanks.
Though the question is a few years old, it's deserving of an answer. I managed to make cross-platform builds for a game built in MonoGame through Mono's mkbundle. Here is a great tutorial for doing so on Windows.
You'll want to download the latest Mono version and append an "exe" extension to the file located at C:\Program Files (x86)\mono\bin\mono. Next download the appropriate runtime for the platform you want to deploy to, give it a "zip" extension, and extract it into the following path: C:\Users\youruserhere\Documents.mono\targets
After that, you should be ready to build; open up a Command Prompt and enter mkbundle --local-targets. If everything went smoothly, the runtimes you have installed should be displayed. After that is a matter of building an exe to the target platform.
Here's an example for building an application to Ubuntu: mkbundle HelloWorldConsole.exe --simple -o HelloWorldBundleUbuntu --cross mono-5.10.0-ubuntu-16.04-x64
Keep in mind that some classes not implemented in Mono, such as WebBrowser, will cause the build to fail. If this is the case, you may need to find a workaround.
With this you can run the file in Linux by entering ./HelloWorldBundleUbuntu in a Terminal. I've had no issues running the game this way in a virtual machine.
Lastly, if you want to go the .NET Core route, MonoGame has a WIP core fork that you can use, though I'm unsure how well it works.
To add to an already year old answer by Kimimaru, there's also the possibility to use MonoKickstart to get your Monogame executables up and running on Mac and Linux without the need to bundle anything. This is especially handy if your projects are a little difficult to bundle, because of third-party libraries or otherwise.
You simply unpack the Kickstart archive and paste your Windows executable ontop. By editing the .kick files to point to the appropriate executable, they will act as an intermediary to run your programs using mono (which is provided, as well, no need to install on target machine).
https://github.com/mrhelmut/MonoKickstart

Porting from Windows to Mac

I have a program on .NET 4 for Windows. I'm trying to port it for Mac computers with mono and Xamarin studio.
I use this code for building:
macpack -m:1 -o:. -r:/Library/Frameworks/Mono.framework/Versions/Current/lib/ -r:/Library/Python/2.7/site-packages/emgucv/lib -r:/Library/Python/2.7/site-packages/emgucv/bin -r:Assimp32.dll -r:Assimp64.dll -r:cvextern.dll -r:Emgu.CV.dll -r:Emgu.Util.dll -r:libegl.dll -r:libglesv2.dll -r:OpenTK.dll -r:OpenTK.GLControl.dll -r:RH.ImageListView.dll -r:blending.fs -r:blending.vs -r:blendingPl.vs -r:idle.fs -r:idle.vs -r:skelet.vs -r:sprite.png -r:./Libraries -r:./Models -r:./Plugin -r:./Resources -r:./Stages -r:./"Haar Cascades" -n:HeadShop -a:RH.MyProgram.exe
where I attach mono lib, emgucv lib and all my dll's from debug folder..
All works good on my machine (where I have mono, xamarin studio and all libs installed), but on a client machine - program doesn't run. It doesn't give any errors, just doesn't appear..
Should user install mono or something else for launch program or my command for building is wrong?
I guess you have to install at least the Mono Runtime. Since it seems not possible to install it alone, you may have to install the Mono Mac Package.
However, since mono translate C# code into Common Intermediate Language you have to install at least something that can interpret that code and translate/run it on the CPU - An installation is needed in any case.

Categories