I got a compile error using Fizzler lib (http://code.google.com/p/fizzler/) in Monodevelop IDE under Ubuntu 10.
I added .Net Assembly References and autocompletion works file, but error during the compilation occurred.
Code here:
using System;
using Fizzler.Systems.HtmlAgilityPack;
using HtmlAgilityPack;
using System.Collections.Generic;
namespace test
{
class MainClass
{
public static void Main (string[] args)
{
HtmlAgilityPack.HtmlDocument html = new HtmlAgilityPack.HtmlDocument();
html.LoadHtml(#"some html");
HtmlAgilityPack.HtmlNode document = html.DocumentNode;
document.QuerySelector("a");
}
}
}
Error CS1061: Type HtmlAgilityPack.HtmlNode' does not contain a definition forQuerySelector' and no extension method QuerySelector' of typeHtmlAgilityPack.HtmlNode' could be found (are you missing a using directive or an assembly reference?) (CS1061) (test)
Are your HtmlAgilityPack.HtmlNode has that definition provided? Check again the API documentation. Please the error is clear by itself.
You may have found the answer to this question by now but I will post one anyway, since people may come across this page while looking for an answer.
Replace:
using Fizzler.Systems.HtmlAgilityPack;
with:
using myFizzler= Fizzler.Systems.HtmlAgilityPack.HtmlNodeSelection;
and call it like this in your project:
HtmlNode h2 = myFizzler.QuerySelector(document, "#fbTimelineHeadline h2");
I hope this helps.
Related
I'm just learning C# so I don't know if I'm just messing up the setup or what, but I used dotnet to create a new project where I'm keeping ALL of my little test scripts. I'm using VS Code as my editor. I create a path variable for csc to compile.
I can compile a Hello World project no problem, but I'm working through this course online and the next part was to make a simple gradebook.
I have GradeMain.cs
namespace Grades
{
public class GradesMain
{
static void Main (string[] args)
{
GradeBook book = new GradeBook();
book.AddGrade(91);
}
}
}
And GradeBook.cs
using System.Collections.Generic;
namespace Grades
{
public class GradeBook
{
public void AddGrade (float grade)
{
grades.Add(grade);
}
List<float> grades = new List<float>();
}
}
When I try to compile using csc I get the following error
error CS0246: The type or namespace name 'Grades' could not be found (are you missing a using directive or an assembly reference?)
My intellisense shows that my GradeBook has two references from GradeMain. I saw this post Referenced Project gets "lost" at Compile Time but since I'm not using visual studio I wasn't sure if it was related / how to check my dotnet client profile.
For me what worked is what #SLaks suggested which was to compile both files with csc.
So runing csc GradesMain.cs GradeBook.cs worked perfectly.
This code:
func = CSScript.CreateFunc<int>(#"int f(int[] inputs) { return inputs.Max(); }");
int max = func(new int[]{ 235,123,675,111 });
is throwing:
error CS1061: 'System.Array' does not contain a definition for 'Max' and no extension method 'Max' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)
I need to inject System.Linq inside my function "func"
....How can I do that?
This is from the CS-Script Documentation:
Hints And Tips
When you need to reference many assemblies (and particularly when these assemblies are commonly used) it is convenient to combine all //css_reference statements into single file containing no code and include this file into your primary script.
The following code includes linq.includes.cs file containing references to all assemblies required for programming against LINQ:
//css_include linq.includes.cs;
using System;
class Test
{
static public void Main( string [] args)
{
....
This is the content of the linq.includes.cs file:
//css_ref System.Core;
//css_ref System.Data.ComponentModel;
//css_ref System.Data.DataSetExtensions;
//css_ref System.Xml;
//css_ref System.Xml.Linq;
When running this code:
using System;
using System.Text.RegularExpressions;
namespace WebAutomationDemo
{
public class ExtractDigitsFromString
{
public static void Main(string[] args)
{
string inputData = "No 38, Bunder Garden Street, Perambur, Chennai - 600011";
var data = Regex.Match(inputData, "/s([a - z][A - Z]) +/s -/s/d[6]").Value;
Console.WriteLine(data);
Console.ReadLine();
}
}
}
I get the following error:
The type or namespace name 'RegularExpressions' does not exist in the namespace 'System.Text' (are you missing an assembly reference?)
This happens even after referencing System.Text.RegularExpressions assembly.
Are you still facing the same error,may be your assembly System is missing RegularExpressions method as stated by many.
Goto Object browser i.e click on any project solutions's references(expand) open any assembly will take it to take object browser window.
Now check whether the System.Text contains the RegualrExpressions method.
Object browser
If you follow the link there is an image of my object browser that do contains System.Text.RegularExpressions assembly.
If its missing ,download a valid assembly from MSDN
Below is one of link for a System.dll,download it or google it you can downlaod it easily.
https://www.dllme.com/dll/files/system_dll.html
Then goto references of your project and then add the downloaded assembly.
I have the following little snippet that won't compile:
using TweetSharp.Twitter.Fluent;
//...
var twitter = FluentTwitter.CreateRequest();
twitter.Authentication.GetRequestToken("...", "...");
...and it gives me the following error:
Main.cs(12,12): Error CS1061: Type `TweetSharp.Twitter.Fluent.
IFluentTwitterAuthentication' does not contain a definition for `GetRequestToken'
and no extension method `GetRequestToken' of type TweetSharp.Twitter.Fluent.
IFluentTwitterAuthentication' could be found (are you missing a using directive
or an assembly reference?) (CS1061) (StackBot)
Which is strange because according to TweetSharp's website, that's supposed to be valid code.
Am I forgetting something or is there some other assembly I need to reference?
I'm using Mono 2.4 on Ubuntu 10.10 64-bit.
I may have found a clue here. Using the assembly browser, I have discovered that IFluentTwitterAuthentication has the following definition:
public abstract interface IFluentTwitterAuthentication : IFluentAuthentication
{
// Properties
public abstract IFluentTwitter Root { get; }
}
...which leads me to believe that something is not quite right with the assembly.
Their code seems to be:
var twitter = FluentTwitter.CreateRequest ()
.Authentication.GetRequestToken("...", "...");
which is quite different than yours:
var twitter = FluentTwitter.CreateRequest();
twitter.Authentication.GetRequestToken("...", "...");
Your USING statements may be missing...Try this:
using TweetSharp.Twitter.Fluent;
using TweetSharp.Twitter.Model;
using TweetSharp.Twitter.Extensions;
//...
var twitter = FluentTwitter.CreateRequest();
twitter.Authentication.GetRequestToken("...", "...");
I am getting this error Error 4 The type or namespace name 'Sample' could not be found (are you missing a using directive or an assembly reference?) F:\oadmin\sea\Controls\Dlg.cs 11 7 Controls
here i added Samplein reference section,,,then i used it as Using Sample,,i dont know why i am getting this error
this is the class
namespace sample
{
public class Server
{
public class client
{
Bool sent = true
}
}
}
Can i share exe,,this Sample is an exe
Perhaps because your namespace is sample and not Sample?
So if your Dlg namespace is different it needs to have a using sample line not using Sample.
Or perhaps your class is in another project within your solution and you need to include the hierarchy of namespaces?
Your namespace "sample" is lowercase, but you are referring to it in uppercase "Sample" ...
EDIT: You Bool sent is internal, it cannot be accessed from outside of the assembly