Reputation: 161
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
Upvotes: 2
Views: 5163
Reputation: 2019
I was able to create .NET core (3.1 in my case) console app running under Windows 10 IoT:
$Env:Path += ";C:\Program Files\dotnet\"
dotnet --info
dotnet .\myapp.dll
Upvotes: 0
Reputation: 21864
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.
Upvotes: 0
Reputation: 563
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).
Upvotes: 1
Reputation: 416
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.
Upvotes: 0
Reputation: 50273
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.
Upvotes: 2