I've just installed Cosmos and tried to run the test program given by default. That's the code:
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);
}
}
}
When I try to compile it, it says:
Error 8 Plug needed. System.Void System.Threading.Monitor.Exit(System.Object)
at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 663
at Cosmos.IL2CPU.ILScanner.ScanQueue() in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 779
at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 284
at Cosmos.Build.MSBuild.IL2CPUTask.Execute() in c:\Data\Sources\Cosmos\source2\Build\Cosmos.Build.MSBuild\IL2CPUTask.cs:line 239 C:\Program Files (x86)\MSBuild\Cosmos\Cosmos.targets 32 10 CosmosKernel2Boot
I'm using Visual Studio 2010, I have installed all requirements listed here: http://cosmos.codeplex.com/releases/view/123476
Thank you in advance!
"plug needed" error means that you have used some method which relies on an internal call or PInvoke, and thus Cosmos cannot compile it.
You probably use a method that has not been plugged yet or maybe missing a reference to that implementation (which makes Cosmos think it is not implemented)
Use the below guides to help you getting started:
http://www.codeproject.com/Articles/220076/Csharp-Open-Source-Managed-Operating-System-Intro
http://www.codeproject.com/Articles/29523/Cosmos-C-Open-Source-Managed-Operating-System
Update: Try using something similar to this code:
using System;
using Cosmos.Compiler.Builder;
namespace CosmosBoot1
{
class Program
{
#region Cosmos Builder logic
// Most users wont touch this. This will call the Cosmos Build tool
[STAThread]
static void Main(string[] args)
{
BuildUI.Run();
}
#endregion
// Main entry point of the kernel
public static void Init()
{
var xBoot = new Cosmos.Sys.Boot();
xBoot.Execute();
//There's supposed to be a bit of text here. Change it to Console.WriteLine("Hello world!");
}
}
}
It seems that Cosmos isn't working well with windows 8/8.1. So the only solution is to either install Windows 7 or run a virtual machine with installed Windows 7 (the latter worked for me)
Related
I'm writing a Console App (.NET Framework) in C#. I want to use arguments from the command line, and I'm trying to use the Command Line Parser library to help me do this.
This is the package on Nuget - https://www.nuget.org/packages/CommandLineParser/
I found out about it from this StackOverflow question - Best way to parse command line arguments in C#?
MWE
using System;
using CommandLine;
namespace CLPtest
{
class Program
{
class SomeOptions
{
[Option('n', "name")]
public string Name { get; set; }
}
static void Main(string[] args)
{
var options = new SomeOptions();
CommandLine.Parser.Default.ParseArguments(args, options);
}
}
}
When I try create a minimal working example, I get an error for options on this line:
CommandLine.Parser.Default.ParseArguments(args, options);
The error is Argument 2: cannot convert from 'CLPtest.Program.SomeOptions' to 'System.Type'
I'm really confused as I have seen this same example code on at least 3 tutorials for how to use this library. (see for example - Parsing Command Line Arguments with Command Line Parser Library)
(This answer is being written at the time of v2.7 of this library)
From looking at their repository's README, it appears as if this is part of the API change that is mentioned earlier in the README. It looks as though the arguments are now handled differently since the example code you reference. So, now you should do something like this inside of Main:
...
static void Main(string[] args)
{
CommandLine.Parser.Default.ParseArguments<SomeOptions>(args);
}
...
To actually do something with those options you can use WithParsed which takes in the options that are defined in your SomeOptions class.
...
static void Main(string[] args)
{
CommandLine.Parser.Default.ParseArguments<SomeOptions>(args).WithParsed(option =>
{
// Do something with your parsed arguments in here...
Console.WriteLine(option.Name); // This is the property from your SomeOptions class.
});
}
...
The C# Example further down the README shows that you can pass in a method into WithParsed to handle your options instead of doing everything within Main.
I'm trying to use the speech recognition functionality in Unity, but when I try to bring it it, Visual Studio isn't recognizing it.
Here's my code:
using UnityEngine;
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Windows.Speech;
using System.Linq;
public class VoiceRecog : MonoBehaviour {
private KeywordRecognizer m_Recognizer;
public KeywordRecognizer keywordRecognizer;
protected Dictionary<string, System.Action> keywords = new Dictionary<string, System.Action>();
void Start() {
Debug.Log("In the Start() of VoiceRecog");
keywords.Add("go", () =>
{
GoCalled();
});
keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());
keywordRecognizer.OnPhraseRecognized += KeywordRecognizerOnPhraseRecognized;
}
void KeywordRecognizerOnPhraseRecognized(PhraseRecognizedEventArgs args) {
Debug.Log("in 2nd function");
System.Action keywordAction;
if (keywords.TryGetValue(args.text, out keywordAction)) {
keywordAction.Invoke();
}
}
void GoCalled() {
Debug.Log("You just Said Go.");
}
}
Unity isn't taking the KeyWordRecognizer type. I think because it's not bringing in UnityEngine.Windows.Speech.
Any ideas about why unityengine isn't being brought in?
To use KeyWordRecognizer, you must include UnityEngine.Windows.Speech at the top. You did this but KeyWordRecognizer is not still recognized.
The possible problem is that you are using older version of Unity. You must have Unity 5.4.0 and above in other to use KeyWordRecognizer.
Unity 5.4.0 Release Note:
Windows: Added speech recognition APIs under
UnityEngine.Windows.Speech. These APIs are supported on all
Also, it is now very easy to find out which version of Unity an API was added. This is a reference for you next time you encounter this problem.
Simply search and find the API then keep bringing the version number down until your current Unity version. The number changes by 10 like 550,540,530....
Available:
Not Available:
We have a "smallish" NServiceBus application(s) that use a dozen EF mapped tables and RabbitMQ as communication medium. With NServiceBus.Host.Exe startup of the application takes ~26s (debug and release versions both, with or without debugger attached).
After adding EndpointConfigurationType application setting the load time dropped by 2s.
So I've been researching this and about 8-10s is spent with EF in the first query and it's various generation routines. EF loading performance could also be enhanced by NGen:ing the libraries.
However after NGen:ing up the libraries and starting NServiceBus.Host.exe, Native images are loaded by default appdomain, but also by an additional appdomain (which uses IL dlls), so it looks like it uses LoadFrom to load up the dependencies.
Is there a way around this? We'd like to use NSB.Host.exe for it's windows service features (that we're not interested in reimplementing). Also the other "IWantTo..." features are nice since we have already several (16?) endpoints using those.
edit: http://blogs.msdn.com/b/abhinaba/archive/2014/02/18/net-ngen-explicit-loads-and-load-context-promotion.aspx
All my dlls are in same directory as NServiceBus.Host.exe, so based on that, Fusion should've loaded the native dlls as well.
edit2: This is "minimal" repro that doesn't have all the b&w of nservicebus.host.exe, but it seems to work in debug situation. It starts in under 2s versus 26s of Nservicebus.host.exe
using NServiceBus;
using BABAR.Configuration;
using System;
using System.Collections.Generic;
using System.Reflection;
namespace BABAR.NGENHelper
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Starting: {0}", DateTime.Now.ToLongTimeString());
StartNSB();
Console.WriteLine("NSB started: {0}", DateTime.Now.ToLongTimeString());
}
private static void StartNSB()
{
// this ends up loading EF, in this case unnoticeable
NServiceBus.Unicast.Transport.TransportConnectionString.Override(
GetRabbitMQConnectionString);
NServiceBus.SetLoggingLibrary.Log4Net(() => log4net.Config.XmlConfigurator.Configure());
var semibus = Configure.With(GetNSBAssemblies())
.DefaultBuilder()
.DefineEndpointName("NGENHelper")
.UseTransport<NServiceBus.RabbitMQ>()
.PurgeOnStartup(false)
.UnicastBus()
.ImpersonateSender(false)
.RunHandlersUnderIncomingPrincipal(false)
.CustomConfigurationSource(new DefaultNServiceBusConfigurationSource())
.MessageForwardingInCaseOfFault()
.DisableTimeoutManager();
var bus = semibus.CreateBus()
.Start(() => Configure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>()
.Install());
}
public static string GetRabbitMQConnectionString()
{
var nc = new Access().GetNode<NodeConfiguration>();
return nc.RabbitConnectionString;
}
internal static IEnumerable<Assembly> GetNSBAssemblies()
{
return new[] {
typeof(NServiceBus.RabbitMQ).Assembly, // IConfigureTransport for NSB
typeof(BABAR.Bootstrapper).Assembly,
};
}
}
}
I think just go with self hosting https://github.com/SimonCropp/NServiceBus.SelfHost#self-host
see sample code for a self host below
The "service features" of the NSB host can be substituted by calls to sc.exe
https://github.com/SimonCropp/NServiceBus.SelfHost#install--uninstall
class ProgramService : ServiceBase
{
IStartableBus bus;
static void Main()
{
using (var service = new ProgramService())
{
// so we can run interactive from Visual Studio or as a service
if (Environment.UserInteractive)
{
service.OnStart(null);
Console.WriteLine("\r\nPress any key to stop program\r\n");
Console.Read();
service.OnStop();
}
else
{
Run(service);
}
}
}
protected override void OnStart(string[] args)
{
Configure.GetEndpointNameAction = () => "SelfHostSample";
bus = Configure.With()
.DefaultBuilder()
.UnicastBus()
.CreateBus();
bus.Start(Startup);
}
static void Startup()
{
//Only create queues when a user is debugging
if (Environment.UserInteractive && Debugger.IsAttached)
{
Configure.Instance.ForInstallationOn<Windows>().Install();
}
}
protected override void OnStop()
{
if (bus != null)
{
bus.Shutdown();
}
}
}
I'm converting an .NET Windows application for Mono to run on Linux (Ubuntu). One of the features depends on a native library (user32.dll). The Mono guide that talks about conversion of applications (Linux Platform Differences) suggests that one approach would be to modify this code.
I'm trying to use GDK to access the Title of a Gdk.Window that I had access through the property Gdk.Global.ActiveWindow. But I found this error at compile time:
Error CS0154: The property or indexer `Gdk.Window.Title` cannot be used in this context because it lacks the `get` accessor (CS0154) (GetActiveWindow)
If i remove the code that reads de Title property of activeW, everything works fine. There is another way to read this property?
Here my unit of work:
using System;
using Gtk;
using Gdk;
using System.Threading;
namespace GetActiveWindow
{
class GdkApp : Gtk.Window
{
public static void Main ()
{
Application.Init ();
new GdkApp ();
Application.Run ();
}
public GdkApp () : base("Simple App")
{
SetDefaultSize (150, 150);
ShowAll();
while (true) {
var activeW = Gdk.Global.ActiveWindow;
Console.WriteLine("Active Window: {0}",activeW.Title); // Where my compile error happens.
Console.WriteLine("Simple App Window: {0}",this.Title); // This code works perfectily.
Thread.Sleep(1000);
}
}
}
}
I think that with Gdk is imposible. Try it with Wnck library giving to a C compiler this '-DWNCK_I_KNOW_THIS_IS_UNSTABLE' and works but with a warning: Unhandled action type _OB_WM_ACTION_UNDECORATE
Sorry I have used genie instead vala.
//valac *.gs --pkg gtk+-3.0 --pkg libwnck-3.0 -X '-DWNCK_I_KNOW_THIS_IS_UNSTABLE'
init
Gtk.init(ref args)
var ventana= new win()
ventana.inicio()
ventana.printinfo()
Gtk.main()
class win:Gtk.Window
won:weak GLib.List of Wnck.Window
def inicio()
var button= new Gtk.Button()
button.clicked.connect(printinfo)
this.add(button)
this.show_all()
def printinfo()
won= Wnck.Screen.get_default().get_windows()
won.foreach(allwin)
def allwin(w:Wnck.Window)
if w.is_skip_tasklist() or w.is_skip_pager()
pass
else
print w.get_name()
this question reltates to TheChange's Question.
The requirements changed so I need to use an extension in Fiddler with the same task.
How can I create an extension with C# which will be excepted by Fiddler?
I can create an dll in C# - I also tried the old .net 2.0 compiler for it.. I first tried to use my extension in the Program-File folder and then in the MyDocuments folder (the two mentioned on the Fiddler-Website).
If I download an extension-dll from Fiddler-extensions it can be used after a restart of Fiddler.
If I try to replace my .dll file while Fiddler is running Windows tells me that the .dll is used by a program and cannot be changed now. The extension is not shown in the extensions-tab.
Right now Iam at dead-end, not knowing what I should search for now as noone else seems to have this problem.
maybe this is needed to answer my question:
using:
MS Visual C# 2008 Express Edition
My Project is in addition linked with Fiddler and System.Windows.Forms (didnt find System.Windows.WinForms which is mentioned on Fiddler).
used [assembly: Fiddler.RequiredVersion("2.2.7.0")] in my extension and my Fiddler is 2.2.8.x.
if this is of interest for the answers: I used IFiddlerExtension-Help description also to get the nessesary code.
My main problem is that Fiddler does not give me any notes or failures but seems to find the extension but cannot use it for some reason.
using System;
using System.Windows.Forms;
using Fiddler;
[assembly: Fiddler.RequiredVersion("2.2.7.0")]
namespace validate_js
{
public interface IFiddlerExtension
{
// Called when Fiddler User Interface is fully available
void OnLoad();
// Called when Fiddler is shutting down
void OnBeforeUnload();
}
public interface IAutoTamper : IFiddlerExtension
{
// Called before the user can edit a request using the Fiddler Inspectors
void AutoTamperRequestBefore(Session oSession);
// Called after the user has had the chance to edit the request using the Fiddler Inspectors, but before the request is sent
void AutoTamperRequestAfter(Session oSession);
// Called before the user can edit a response using the Fiddler Inspectors, unless streaming.
void AutoTamperResponseBefore(Session oSession);
// Called after the user edited a response using the Fiddler Inspectors. Not called when streaming.
void AutoTamperResponseAfter(Session oSession);
// Called Fiddler returns a self-generated HTTP error (for instance DNS lookup failed, etc)
void OnBeforeReturningError(Session oSession);
}
public class Violin : IAutoTamper
{
string sUserAgent = "";
public Violin()
{
sUserAgent = "Violin";
}
public void OnLoad()
{
string strResponse;
FiddlerApplication.Log.LogString("S&T-Script wird ausgeführt.");
Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS)
{
strResponse = oS.GetResponseBodyAsString(); // safe BodyContent in strResponse
if (System.String.Compare(strResponse, "getElementbyID", true) == 0)
{
FiddlerApplication.Log.LogString("getElementbyID found - could have a different attitude in IE 8. Please check");
}
};
}
public void OnBeforeUnload()
{
}
public void AutoTamperRequestBefore(Session oSession)
{
oSession.oRequest["User-Agent"] = sUserAgent;
}
public void AutoTamperRequestAfter(Session oSession) { }
public void AutoTamperResponseBefore(Session oSession) { }
public void AutoTamperResponseAfter(Session oSession) { }
public void OnBeforeReturningError(Session oSession) { }
}
}
I would apreciate any help possible...
You're redeclaring the IAutoTamper and IFiddlerExtension interfaces within your namespace, which "hides" the real interfaces within the Fiddler namespace.
If you delete those interface redeclarations from your code (leaving just your Violin class), you will find that your DLL works just fine.