Cosmos basic example does not run - c#

I am trying to get started with Cosmos using C#. I installed Visual studio 2017, and Cosmos user kit.
On many tutorials on youtube, I have seen that the VMWare player starts whenever they press the "run" button.
However, in my case, I get the following error:
"A project with an Output type of class library cannot be started directly."
My code is really simple, and it is the basic example given in the documentation. Please help me to solve this issue.
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
namespace CosmosKernel2
{
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
}
protected override void Run()
{
Console.Write("Input: ");
var input = Console.ReadLine();
Console.Write("Text typed: ");
Console.WriteLine(input);
}
}
}

Cosmos is a kernel. You can't "run a kernel on windows". If you want to run your cosmos kernel straight out of Visual Studio you need a virtual machine.
Cosmos uses Vmware out of the box. Make sure you have it installed.
Alternatively you can use VirtualBox, I personally got it to run on that too.
You can also run it on an actual machine with a bootloader, like Grub. You can dual boot into windows or your own kernel that way.
Cosmos has instructions here: https://github.com/CosmosOS/Cosmos/wiki/Deployment
Set the boot that cosmos generates as startup project to run it.

Related

Arduino driver issues (Causing exceptions)

I'm attempting to use ArduinoDriver (through NU-Get) to connect to my Arduino Uno R3 in Visual Studio (in C#). This is the code I'm attempting to run:
using ArduinoUploader;
using ArduinoUploader.Hardware;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ArduinoDriver.SerialProtocol;
using System.Threading;
using ArduinoDriver;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
var driver = new ArduinoDriver.ArduinoDriver(ArduinoModel.UnoR3, "COM3", true);
driver.Send(new DigitalWriteRequest(13, ArduinoDriver.DigitalValue.Low));
driver.Send(new DigitalWriteRequest(13, ArduinoDriver.DigitalValue.High));
Console.WriteLine("doing it!");
}
}
}
The code compiles correctly. However I'm getting an exception at runtime on line 18 (the new Driver Instantiation) in the form of:
System.MissingMethodException: 'Method not found: 'Void ArduinoUploader.ArduinoSketchUploader..ctor(ArduinoUploader.ArduinoSketchUploaderOptions)'.'
I have checked and double-checked the package and dependencies and they are all installed and up to date.
I have also tried both false and true for the AutoBootstrap option in the Arduino Driver Constructor. When it is set to true, the results are as above. When set to false I receive the following exception instead:
System.IO.IOException: 'Unable to get a handshake ACK when sending a handshake request to the Arduino on port COM3. Pass 'true' for optional parameter autoBootStrap in one of the ArduinoDriver constructors to automatically configure the Arduino (please note: this will overwrite the existing sketch on the Arduino).'
I should also point out that I have checked the port for the Arduino and it is definitely connected to COM3 (tested and working in the Arduino I.D.E).
Finally on running the script in Visual Studio, the Arduino flashes its lights in the way that it normally would when a successful upload is in progress. However it hangs for a couple of seconds at the driver instantiation and then puts out the exceptions.
If anyone out there can shed some light on this that would be amazing, I have googled like crazy and have not found any tutorials or other people dealing with this issue. Please let me know if any further info is required.
Cheers!
Using Windows 10 Bootcamped (Mac)
I got the same MissingMethodExeption. I synchronized the packages ArduinoDriver and ArduinoUploader (i.e. in my case downgrading the ArduinoUploader form v3.0.0 to v2.4.5) using the NuGet package manager.
This solved the issue for now...
I copped a tumbleweed badge on this one, so I think I have discovered my own answer; which is to use visual micro, and never speak of Arduino Driver again.
cheers!

How can I create and access test cases in Team Foundation Server using visual C# console

I am working with VS C# to manipulate test cases, create projects, and anything else that's beneficial to my testing in TFS. However, there are not any solid examples out there. The API that is on the Microsoft Developer site is just not helpful to me (could be my lack of experience in coding in VS), but I am becoming frustrated. Any progress that I make takes several days ( ... really hit and miss). Can someone direct me to a consolidated resource for using the team foundation server object model to implement features programmatically: WebSites, Books, etc...? Thanks!!! Below is what appears to be very straightforward code to create a Default collection/Project and write a test case in VSO TFS with C# (It continues to fail):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.TestManagement.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace myProject
{
class Program
{
static void Main(string[] args)
{
string serverurl = "http://localhost:8080/tfs";
string project = "Beta1";
ITestManagementTeamProject proj = GetProject(serverurl, project);
ITestCase tc = proj.TestCases.Create();
tc.Title = "Test";
tc.Save();
Console.WriteLine("TC: {0}", tc.Id);
}
static ITestManagementTeamProject GetProject(string serverUrl,
string project)
{
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullQualifiedUriForName(serverUrl));
ITestManagementService tms = tfs.GetService<ITestManagementService>();
return tms.GetTeamProject(project);
}
}
}
The serverul "http://localhost:8080/tfs" in your code snippet means you are handling with on-premise TFS. But in your description, you want to create a test case work item in Visual Studio Online.
For Visual Studio Online api, you can refer to Visual Studio Online REST API at website:
https://www.visualstudio.com/en-us/integrate/api/overview
For deal with on-premise TFS programmatically, you can refer to blogs below:
http://joymonscode.blogspot.in/2009/05/beginning-tfs-programming.html
http://geekswithblogs.net/TarunArora/archive/2011/06/18/tfs-2010-sdk-connecting-to-tfs-2010-programmaticallyndashpart-1.aspx

Performance and diagnostics with "Cannot start service... A Windows Service must first be intalled (using installutil.exe)..."

Presently, I am attempting to profile a Windows service that I am working on using the new "Performance and Diagnostics" feature in Visual Studio 2013 (see http://blogs.msdn.com/b/visualstudioalm/archive/2013/07/12/performance-and-diagnostics-hub-in-visual-studio-2013.aspx). When I attempt to profile the service, I get this error message:
Cannot start service from the command line or a debugger. A Windows Service must first be intalled (using installutil.exe) and then started with the ServerExplorer, Windows Services Administrative Tool or the NET START command.
Normally when debugging the service, it works fine because I have the following code in Program.cs:
private static MySvc _serviceInstance;
private static readonly List<ServiceBase> _servicesToRun =
new List<ServiceBase>();
static void Main(string[] args)
{
_servicesToRun.Add(_serviceInstance);
if (Environment.UserInteractive)
{
_servicesToRun.ToArray().LoadServices();
}
else
{
ServiceBase.Run(_servicesToRun.ToArray());
}
}
static Program()
{
_serviceInstance = new MySvc();
}
Also, if I attempt to attach to a running app, in the dialog that appears it doesn't display any executing processes, and when I put the name of the service in there, it does not find it. Does anyone have any suggestions? TIA.
UPDATE: This is what I get when I attempt to attach to a process. Why doesn't the "Performance and Diagnostics" see any processes running on my computer? Why would it only connect to Windows Store apps instead of all exes? Please see this image:
The way I resolved the problem was the copy all the source code and make minor modifications to get everything to run in a Console application, then chose Debug->Performance and Diagnostics and ran the Console application using "Change Target" -> "Launch and executable file (.exe)"

Facebook API in a console application

I am new to using Facebook Api and I am using it in visual studio C# , and I downloaded it's library facebook. But I want to know how to start work on it ? Should I use Windows form for it or Console is fine ? Because I just want to Update my status through Api , getting my friend list , read my statuses .
As I run this code before but It didn't show me the output
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Facebook;
namespace Social_network_work
{
class Program
{
static void Main(string[] args)
{
var client = new FacebookClient();
dynamic me = client.Get("totten");
}
}
}
as I am python user but now I have to use visual studio c#. "http://csharpsdk.org/" this link is not showing how to use it in windows 7
Your question doesn't have much to do with Windows 7.
You sample works fine. You just don't have any line writting to the console.
Try :
var client = new FacebookClient();
var me = client.Get("totten");
Console.WriteLine(me);
To keep the command-line open so you can read the output, add the following after
the Console.Writeline line
Console.Readline();
Then when you run it, the output will display, and wait for you to press enter - which will allows the program to continue and exit/quit.
Also, in short, yes you should be able to create the app as a complete command-line application without issue.

Keep C# application running

I'm building a Windows Service that uses FileSystemWatcher, and runs in the background.
I don't want to keep on uninstalling and installing the service every time I want to debug, so would like to do most of my development in a normal program before moving it into a service. But I'm quite new to this, and when I run it, it just runs through the block and exits.
What would be a good way to keep the program running?
http://einaregilsson.com/run-windows-service-as-a-console-program/
I've used this before to debug my service as a Console application based on whether its running in an interactive user environment.
public partial class DemoService : ServiceBase
{
static void Main(string[] args)
{
DemoService service = new DemoService();
if (Environment.UserInteractive)
{
service.OnStart(args);
Console.WriteLine("Press any key to stop program");
Console.Read();
service.OnStop();
}
else
{
ServiceBase.Run(service);
}
}
while (true)
{
// Execute your program's functionality here.
}
I wrote a 7 part series a while ago titled: Building a Windows Service. It covers all the intricacies of building services, making them friendly to debug, and self-installing.
The basic feature set I was looking for was as follows:
Building a service that can also be used from the console
Proper event logging of service startup/shutdown and other activities
Allowing multiple instances by using command-line arguments
Self installation of service and event log
Proper event logging of service exceptions and errors
Controlling of start-up, shutdown and restart options
Handling custom service commands, power, and session events
Customizing service security and access control
The final result was a Visual Studio project template that creates a working service, complete with all of the above, in a single step. It's been a great time saver for me.
see Building a Windows Service – Part 7: Finishing touches for a link to the project template and install instructions.
Here’s documentation from MSDN # http://msdn.microsoft.com/en-us/library/7a50syb3(v=vs.80).aspx?ppud=4 . I have tried it before and it works under .NET Framework 3.x. I could not find my descriptive notes on it, at the moment.
Use the pragma #If DEBUG for debugging purposes like console outputs. Another is using the Debug object.
If you have any trouble with this, say so. I may be able to find my notes or make a Windows Service app myself, just to see if the steps on MSDN still work.

Categories