I'm trying to make application that would take a picture using web-camera on Raspberry PI running Windows IoT. The problem is that I can't find console app template.Universal Windows blank app template provides me with GUI but I'm going to call this app from python script so it should be without one.
Windows IoT projects provide background task template but the output is .winmd file and I cant execute it from python neither.
What is the way to create simple console app in Windows IoT using c#?
Thanks
Console applications are supported in Windows IoT but apparently in C++ only. Perhaps you could try to create a solution that has a very simple C++ console application that just handles interaction with the user plus a C# class library with all the logic and hardware related code.
Seems to works with a standard c# console apps. How I found out?
I used Reflector and examined all exe files in c:\windows\system32 on the Pi, and one was a .NET assembly: netcmd.exe
When I look at netcmd.exe in Reflector, it says it's build with standard .NET 4.5, this can't be right? But I made a standard c# console app with framework 4.5, added this:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello world");
}
}
put the test.exe on the Pi, and voila:
C:>test
Hello world
Weirdest thing.
I haven't tested more than this, but I imagine You get into trouble with unimplemented API's since only a subset of .NET (same as in Background Application (IoT)?) exist on the Pi, so you must "manually" take care not use unimplemented stuff (or code most in Background Application "mode", and in the final stage, move to standard .NET 4.5 and add the console code).
If you still wish to move forward using C#, it may be sufficient to create the application as a blank Universal Windows Platform application as 1.) The UI will not be instantiated if the RPi2 is powered on without a connected HDMI cable 2.) You may find it useful to use the included UI as a means of live-debugging your application.
If you use your Win 10 device for a single (or multiple) app that all do not need a GUI, (eg for service apps only), you can boot the device with the headless option.
This boots without the whole UI with an extra resource bonus., buts still can be accessed over the network.
display the current state of your device, use the setbootoption utility:
[192.168.0.243]: PS C:\> setbootoption.exe
To modify the state of your device to enable headless mode, use the setbootoption utility with the headless arg:
[192.168.0.243]: PS C:\> setbootoption.exe headless
[192.168.0.243]: PS C:\> shutdown /r /t 0
To modify the state of your device to enable headed mode, use the setbootoption utility with the headed arg:
[192.168.0.243]: PS C:\> setbootoption.exe headed
[192.168.0.243]: PS C:\> shutdown /r /t 0
The device will start up with a black screen.
I was able to create .NET core (3.1 in my case) console app running under Windows 10 IoT:
Create a .net core console app and publish it to a folder
Connect to the device in windows explorer (or ftp) with 10.0...\c$
Create a folder in c:\program files\dotnet
Download an arm 32 dotnet core runtime (for example https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-aspnetcore-
3.1.2-windows-arm32-binaries) (note I've used a raspberry pi 4)
Unpack it inside the folder at point 3
Open a powershell terminal to device (https://learn.microsoft.com/en-us/powershell/scripting/getting-started/getting-started-with-windows-powershell?view=powershell-7)
In powershell add the dotnet path to path env variable:
$Env:Path += ";C:\Program Files\dotnet\"
Check dotnet is available with:
dotnet --info
Finally copy your application output (publish folder) over the device
You should be able to run:
dotnet .\myapp.dll
Related
I have a dotnet app, which I'm running on a Raspberry PI. I don't have a way to run full-fledged IDE on it, like Visual Studio or Rider. I run it on Raspberry PI with dotnet run. Since the app depends on some Raspberry PI hardware specifics, I cannot run it anywhere else.
I noticed that sometimes the app gets stuck somehow and the logs are no longer being generated. How can I find out which place in my code is the place where runtime is stuck? I don't see any exceptions. I can't even exit the app with SIGINT. I have to kill -9 it.
You can publish your application in Debug configuration and use remote debugging via SSH (first of all you need to configure SSH on raspberry). More information here: https://learn.microsoft.com/en-us/visualstudio/debugger/remote-debugging-dotnet-core-linux-with-ssh?view=vs-2022
I'm making the transition from windows to linux with dotnet core 3.1 console apps but not seeing the console app output on terminal window
i've installed the dotnet core runtime on debian
I built the solution using
dotnet publish -c Release --self-contained --runtime debian-x64
Then I used winSCP to copy the files to the usr/local/release folder
in the terminal i browse to folder and run using ./myappname
the terminal window seems like its doing something, but i see no output, if i ctrl z, it then prints 'stopped'
Should i be seeing the console app output on terminal screen? if not, what command do i use to see the console.writeline output?
The app should first print name of running app, then every 1 min print out stats to screen (this is what is does on windows)
this is quite a basic app but unfortunately does not log to file.
so it turned out someone had used
Console.Title = "blah";
at top, that doesn't work on linux, but the I got no errors when publishing as linux to tell me its not supported
I created a UWP-application which starts an external application over its EXE-File using the FullTrustedLauncher.
It works fine when I start the UWP-App on the computer (local) but the problem occurs when I start the UWP-app on a Raspberry Pi.
The EXE-File can't be run with following Error: "Class not referenced"
By the way the EXE-File I want to run is an ASP.NET Core application.
Am I missing some .dll-files or what should I do to start an EXE on a Raspberry Pi? Are there better alternatives than using the FullTrustedLauncher for UWP-applications?
Thanks for your help :)
You should be able to use ProcessLauncher API in Windows IOT. Here is a sample and documentation: https://github.com/Microsoft/Windows-iotcore-samples/blob/master/Samples/ExternalProcessLauncher/CS/README.md
FullTrustProcessLauncher is a Desktop Extensions SDK API, as called out in the documentation. It is only supported (and present) on the desktop device family, not on iot or any other SKU of Windows.
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);
I've implemented a DNX (dnx451) 'console app' which is intended to run as a background service. On Windows I would just turn it into a Windows Service. What is the proper way to do this on Linux (for instance, Ubuntu)?
EDIT:
Found more info here: How to migrate a .NET Windows Service application to Linux using mono?
On Unix/Linux operating system you can turn any program into a background service like
dnx run &
The "&" turns the "dnx run" it into a background program (when I remember right for your current shell session). For real background services look at the startup scripts of common Unix daemons like mysql or apache httpd. They get started by the initd/systemd processes and then execute on their own.