I tried to run my program using Visual Studio's Coderunner extension as well as from terminal with the scriptcs command.
My code is as follows:
using System;
namespace HelloWorldApplication {
class HelloWorld {
static void Main(string[] args) {
Console.WriteLine("hellowol");
}
}
}
The error message reads:
Unexpected named argument: Users/jfitz/Projects/C#/Projtest/test.cs
As mentioned in scriptcs/scriptcs issue 1188, this is from a scriptcs bug, which will be fixed in the next release (PR 1289 and commit 9e49b72)
In the meantime, pending the next 0.18 scriptcs release:
The workaround is the following:
instead of doing
mono scriptcs.exe /path/to/foo.csx
do:
mono scriptcs.exe -script /path/to/foo.csx
Jonas suggests in the comments:
For Visual Studio Code, add this to settings.json:
"code-runner.executorMap": { "csharp": "scriptcs -script" }
Related
Hi I am getting "cd "c:\Users\UMUT\Desktop\Unity Projects\Newest\Assets" ; if
($?) { dotnet run $Player_Movement }" message and I get this error message "Couldn't find a project to run. Ensure a project exists in C:\Users\UMUT\Desktop\Unity Projects\Newest\Assets, or pass the path to the project using --project." in my Vs code Unity project. İn my another old project I have a C# script named Player_Movement but I am getting this error in my new Unity Project when I try to debug the project.I downloaded C# extension.I downl Any solutions or reason why it is happening?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class New : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Debug.Log("hi");
}
// Update is called once per frame
void Update()
{
}
}
I resetted Vs code settings and change my C# extension to older version and error fixed.
I reseted Vs code settings to default and my problem is fixed.
i can't use Syetem.Data.SqlClient.
this is my code
using System;
using System.Data.SqlClient; // <== error
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
i make this project from console, and input 'dotnet new' and restore.
what shold i do?
Have you added "System.Data.dll" to your project reference?
Add reference for SQL server data from project references. If there is not such option then run the Setup of visual studio select option Modify and then select SQL data option and run the setup.
First I've installed the latest Edge Nuget Package. Then I'm running the basic hello world starting example and have been running into this error on Windows 2010 w/ Visual Studio 2015.
When I execute the same hello world code on OS-X I get this error.
Here's a break out of the locals variable tree. Looks like the error might be similar.
The code looks like this. It is literally copied from the README.md of the repo.
using System;
using System.Threading.Tasks;
using EdgeJs;
class Program
{
public static async void Start()
{
var func = Edge.Func(#"
return function (data, callback) {
callback(null, 'Node.js welcomes ' + data);
}
");
Console.WriteLine(await func(".NET"));
Console.ReadKey();
}
static void Main(string[] args)
{
Task.Run((Action)Start).Wait();
}
}
Resolved this problem by copying the folder edge into the bin folder.
Reference: https://github.com/tjanczuk/edge/issues/565#issuecomment-315343743
When you install Edgejs from nuget it creates an edge folder in your solution. Node.dll should be in your x64 & x86 folders.
I have tried many different ways. I completed a compile with the NDK and when I run it on an emulator with the adp shell, I get no output.
mono-3.10.0 from a tarball
Here are my environment variables:
export CC=i686-linux-android-gcc
export SYSROOT=/home/XXUSERNAMEXX/Develop/android-ndk-r10d/platform/android-17/arch-x86
export PATH=/tmp/my-android-toolchain/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Here is my configure:
./configure --disable-mcs-build --host=i686-linux-android --prefix=/home/XXUSERNAMEXX/vmshare/workspace/HelloJni/jni/mono-2.0 --target=i686-linux-android --build=i686-linux-gnu
then just
make
then
make install
Then build a C# sample of just:
// HelloAndroid.cs
// Outputs HelloAndroid.exe
using System;
namespace HelloAndroid
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine ("Hello World!");
}
}
}
then I copy
mono-sgen
libmonosgen-2.0.so
HelloAndroid.exe
to an android directory of
/data/data/com.example.helloandroid
change all the permissions to 755
change all the ownerships to system:system
then type
./mono-sgen HelloAndroid.exe
in the adp shell
then I just get nothing.
no errors, no output, just the command line returns
You need to compile the .NET Assemblies (System.dll ...) like for regular host and to put them into Android.
In addition define MONO_PATH to mono runtimes.
I am running Mono version 2.10 on Ubuntu 11.10. I am trying to run the sample provided on http://blog.davidebbo.com/2012/02/quick-fun-with-monos-csharp-compiler-as.html ,but it seems to target a different version of mono. For instance Compile is a static method on Evaluator. I have made the following changes to his sample, but haven't got it working. Can anyone provide the correct changes, and does anyone know if there is any info on the API changes to Mono.CSharp? The version reported by my compiler is as follows:
$ dmcs --version
Mono C# compiler version 2.10.5.0
I compiled the following code using this command line:
dmcs -r:Mono.CSharp Sample.cs
And got this warning when compiling.
dmcs -r:Mono.CSharp Sample.cs
Sample.cs(26,17): warning CS0219: The variable `compiledMethod' is assigned but its value is never used
Compilation succeeded - 1 warning(s)
This is the result of running the code:
$ ./Sample.exe
{interactive}(2,40): error CS1525: Unexpected symbol `namespace', expecting `end-of-file' or `using'
{interactive}(4,70): error CS0101: The namespace `UserCode' already contains a definition for `Foo'
{interactive}(4,70): (Location of the symbol related to previous error)
This is the Code I have so far:
using System;
using System.IO;
using Mono.CSharp;
using System.Reflection;
namespace Sample
{
public interface IFoo { string Bar(string s); }
class Program
{
const string code = #"
using System;
namespace UserCode
{
public class Foo : Sample.IFoo
{
public string Bar(string s) { return s.ToUpper(); }
}
}
";
static void Main(string[] args)
{
Mono.CSharp.Evaluator.Init(new string[] {} );
Evaluator.ReferenceAssembly(Assembly.GetExecutingAssembly());
var compiledMethod = Evaluator.Compile(code);
for (;;)
{
string line = Console.ReadLine();
if (line == null) break;
object result;
bool result_set;
Evaluator.Evaluate(line, out result, out result_set);
if (result_set) Console.WriteLine(result);
}
}
}
}
Mono 2.10 comes with Evaluator supporting expressions and statements only. Your code contains type declaration which is not supported by Mono 2.10.
Mono 2.11 or git master Mono.CSharp have support for type declarations and other advanced features.
According to this: http://www.mono-project.com/Release_Notes_Mono_2.12#Instance_API , the static/global Evaluator is the older API and the Instance API is the newer one. The Mono I have is the current stable version (2.10) and Mono.CSharp that comes with version 2.11 has the instance methods. 2.12 doesn't look to have been released yet.
Here's another mention of the instance API to the Compiler as a service: http://tirania.org/blog/archive/2011/Oct-14.html