using System;
using SplashKitSDK;
public class Program
{
public static void Main()
{
console.WriteLine("Hello World");
}
}
Some of the errors I am getting:
Unnecessary using directive. [Helloworld]csharp(CS8019)
The type or namespace name 'System' could not be found (are you missing a
using
directive or an assembly reference?) [Helloworld, Helloworld, Helloworld,
Helloworld]csharp(CS0246)
Predefined type 'System.Object' is not defined or imported
The name 'Console' does not exist in the current context
I've tried everything, and nothing seems to work. I also believe I installed the language tools and library correctly. If anyone knows how to fix this please let me know. Thanks!
Related
Part Of My Code:
public void Move(Point newLocation)
{
if (newLocation == null)
throw new ArgumentNullException("newLocation");
Move(newLocation.X, newLocation.Y);
}
I get this as a Error:
The type or namespace name 'ArgumentNullException' could not be found (are you missing a using directive or an
assembly reference?)
Is there something wrong with my c# code. Could this be a VS Code C# support extension bug?
I am a beginner to c# please explain
ArgumentNullException is in the "System" namespace. So either fully-qualify the name,
throw new System.ArgumentNullException("newLocation");
or add
using System;
to the top of your C# file or your namespace.
I'm trying to set up serialization for a class. When I added:
[Serializeable]
I got the error:
"The type or namespace name could not be found (are you missing a using directive or an assembly reference?)"
I added System.Runtime.Serialization.Formatters.Soap and System.Runtime.Serialization but they didn't work. I also tried to find the other assemblies listed on the documentation page. I only found mscorlib in the VS Reference Manager and it was already added.
I wrote the code like so:
[Serializeable]
public class Test { }
Edit: I also tried:
[Serializeable()]
public class Test { }
I expected the code to compile without errors.
Edit: fixed wrong name for an assembly
Per MSDN, the SerializableAttribute type can be found in the following assemblies:
System.Runtime.Serialization.Formatters.dll
mscorlib.dll
netstandard.dll
System.Runtime.dll
EDIT
It may be easier to try the below. There may be namespace conflicts.
[System.SerializableAttribute]
public class Test {}
I have a USQL Job which reads json from Azure Blob and after some data manipulation writes a single line JSON file to ADLS.
I have written a Custom Ouputter to write JSON File.
This is how my CustomOutputter files look like:
using Microsoft.Analytics.Interfaces;
using Microsoft.Analytics.Types.Sql;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Newtonsoft.Json;
namespace demo{
[SqlUserDefinedOutputter(AtomicFileProcessing = true)]
public class JSONOutputter : IOutputter
{
//Actual Code Here
public static class Factory
{
public static JSONOutputter JSONOutputter(bool isHeader = true, Encoding encoding = null)
{
return new JSONOutputter(isHeader, encoding);
}
}
}
I am using this Ouputter in my USQL Job like this:
OUTPUT #final_output
TO "/output/json/final.json"
USING demo.Factory.JSONOutputter(isHeader: true);
When I compile my USQL Script using
ADL: Compile Script
I get this error:
[Info] Start compiling code behind: /users/kumar.pratik/documents/usql/second.usql.cs ...
[Error] Command failed: mono /Users/kumar.pratik/.vscode/extensions/usqlextpublisher.usql-vscode-ext-0.2.11/compilehost/compilehost.exe /users/kumar.pratik/documents/usql/second.usql.cs /Users/kumar.pratik/Documents/usql/usqlCodeBehindReference /Users/kumar.pratik/Documents/usql/second.usql.dll __codeBehind__tRYGlFBeSWcl
[Error] Compile failed
error: "The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)" at line: 8, column 6
error: "The type or namespace name 'JsonTextWriter' could not be found (are you missing a using directive or an assembly reference?)" at line: 17, column 12
error: "The type or namespace name 'JsonTextWriter' could not be found (are you missing a using directive or an assembly reference?)" at line: 44, column 34
Could someone please let me know how can I get this fixed?
I am working on Visual Studio Code on Mac OS
Thanks
Can you please share how your script looks like? In particular, are you
Using Visual Studio's code behind for your Outputter code?
If the answer to 1 is no: Did you register your Outputter and Newtonsoft lib in the U-SQL catalog with CREATE ASSEMBLY or via the Visual Studio Assembly registration feature? And did you reference the U-SQL assemblies (both your own code and Newtonsoft) in your script with REFERENCE ASSEMBLY?
More details: https://blogs.msdn.microsoft.com/azuredatalake/2016/08/26/how-to-register-u-sql-assemblies-in-your-u-sql-catalog/
I am trying to write a text in the main wikipedia page using Web Driver but i can't manage to figure out why do I have these errors?
private void button1_Click(object sender, EventArgs e)
{
IWebDriver driver = new FirefoxDriver();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
driver.Navigate().GoToUrl("http://en.wikipedia.org/wiki/Main Page");
IWebElement searchInput = driver.FindElement(By.Id("searchInput"));
searchInput.SendKeys("web driver");
}
Error 1 The type or namespace name 'Attributes' does not exist in the
namespace 'Enigmatry.Selenium.Tools' (are you missing an assembly
reference?)
Error 2 The type or namespace name 'SeleniumTestBase' could not be
found (are you missing a using directive or an assembly reference?)
Error 3 The type or namespace name 'IgnoreConfigAttribute' could not
be found (are you missing a using directive or an assembly
reference?)
I'm sorry for the noobness but I don't seem to figure what is SeleniumTestBase and where I've used it. Can someone advise me what to do?
This might be a C#-noob question...
Assume I have the following CLI/C++ header:
namespace DotNet {
namespace V1 {
namespace X {
public ref class AClass {
public:
AClass() {}
void foo() {}
static void bar() {}
};
}
}
}
Then from C# I do the following:
using DotNet;
V1.X.AClass a = new V1.X.AClass();
I get:
Program.cs(18,7): error CS0246: The type or namespace name 'V1' could
not be found (are you missing a using directive or an assembly
reference?)
Same with:
using DotNet.V1;
X.AClass a = new X.AClass();
Program.cs(18,7): error CS0246: The type or namespace name 'X' could
not be found (are you missing a using directive or an assembly
reference?)
What works is:
DotNet.V1.X.AClass a = new DotNet.V1.X.AClass();
Or
using DotNet.V1.X;
AClass a = new AClass();
So either I have to use the full namespace path, or I have to open all of the path to access the class. Is there anything I can do about this?
I would like to be able to open only a part of it.
So either I have to use the full namespace path, or I have to open all of the path to access the class.
Yes.
Is there anything I can do about this?
Not that I'm aware of. Why would you not just want a using directive for the whole namespace? Isn't that the simplest approach?
Note that this has nothing to do with C++/CLI. The same is true whatever the source language is - so you can see it with C# as well:
namespace DotNet.V1.X
{
public class AClass {}
}
As Jon Skeet stated you have to include the full namespace in either the using statement or each time you reference it in code. I recommend just placing the full namespace in the using statement.
You can, however, achieve that syntax with a using alias, but it does not add anything of value outside of syntax.
using V1 = DotNet.V1;
...
V1.X.AClass a = new V1.X.AClass();
Also if you are using C# version 3.0 or higher the var keyword will only require you type out the full namespace on the right side of the assignment.
var a = new DotNet.V1.X.AClass();