This seems obvious but I cannot see an easy way to to do this.
I have written a C# Program in LinqPad and it runs well, is there a guide for moving this to a Visual Studio Console Program.
A simple program such as this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
DataContext dataContext = this;
var products = dataContext.GetTable<Product>();
var query = from p in products
select p;
query.Dump();
}
}
}
produces these errors:
Error 1 The type or namespace name 'DataContext' could not be found (are you missing a using directive or an assembly reference?) c:\users\xxx\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs
Error 2 Keyword 'this' is not valid in a static property, static method, or static field initializer c:\users\xxx\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs
Error 3 The type or namespace name 'Product' could not be found (are you missing a using directive or an assembly reference?) c:\users\xxx\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 14 49 ConsoleApplication1
I must have to add some references, add a connection to the database, I just need a guide for what to add to my project but I cannot find one.
Related
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/
Trying to build the test project below, I get this error:
Error: The type or namespace name 'IHttpActionResult' could not be
found (are you missing a using directive or an assembly reference?)
In the "Reference Manager" dialog, Assemblies/Framework, I ticked the System.Web.Http box.
Here is the source:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
namespace dotNET45_test
{
class Program {
static void Main(string[] args) { }
}
class Test : IHttpActionResult { // <-- Error
}
}
Is anything missing in the source code, or in the project settings?
using System;
using System.Collections;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.CustomMarshalers;
namespace mshtml
{
[DefaultMember("item"), CompilerGenerated, Guid("3050F21F-98B5-11CF-BB82-00AA00BDCE0B"), TypeIdentifier]
[ComImport]
public interface IHTMLElementCollection : IEnumerable
{
void _VtblGap1_3();
[DispId(-4)]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(EnumeratorToEnumVariantMarshaler))]
IEnumerator GetEnumerator();
}
}
The above code gives me the following error:
Error CS0234: The type or namespace name 'CustomMarshalers' does not exist in the namespace 'System.Runtime.InteropServices' (are you missing an assembly reference?)
Pleae advise how to fix? It's a decompiled code, and I am very beginner in C#.
You have to include CustomMarshalers.dll
Example:
Add the reference using Project -> Add Reference -> Browse -> Go to location "C:\Windows\assembly\GAC_32\CustomMarshalers\2.0.0.0__b03f5f7f11d50a3a" -> Select CustomMarshalers.dll
Sorry for resurrecting an old thread. With Framework 4.72, you can use Project -> Add Reference -> Assemblies -> Check the box next to CustomMarshalers.
I am trying to process XML with C# in Visual Studio and it will not allow me to import System.Xml. I looked at other posts about this problem and this was usually caused by misspelling System.Xml to System.XML. I have the right spelling so I am not sure what is causing me problems. I looked under references and there is no System.Xml and I am using Visual Studio 2013 The error message was
Error 1 The type or namespace name 'Xml' does not exist in the namespace 'System' (are you missing an assembly reference?)
Do I have to download System.Xml?
Here is the code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace WebTesting
{
class Test1
{
public static void Main(string [] args)
{
using(XmlReader reader = XmlReader.Create("myData.Xml"))
{
while(reader.Reader())
{
if(reader.IsStartElement())
{
Console.Write("The start element is " + reader.ReadString());
}
}
}
Console.ReadLine();
}
}
}
You'll need to add an assembly reference. Right-click "References" under your project in Solution Explorer and select "Add Reference..." Switch to the .NET tab and find System.Xml. Click OK.
by using XDocument (in using System.Xml.Linq;) you'll get more flexible functionality to handling XML-documents
I am using an online IDE (http://www.frosthawk.net/) to run my C# code and upon compilation I get the error
Error Id: CS0234, Error: The type or namespace name 'Xml' does not exist in the namespace 'System.Security.Cryptography' (are you missing an assembly reference?), Line: 26, Column: 36
Can anybody tell me how to add this reference to my code whicle using the the online IDE as I cannot right click and Add Reference that we used to do normally
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Xml;
public class SignVerifyEnvelope
{
public static void Main(String[] args)
{
try
{
......
Perhaps you missed this:
// IMPORTANT How-To-Use:
// # Add/Manage References by clicking the 'References' link
// # Manage Your Build Settings by clicking the 'Settings' link
Click references and fix your reference.
If you are unsure which reference you require, you may need to browse MSDN for help. For reference here is the System.Security namespace.