I am trying to load a certain page though WebBrowser control while avoiding unnecessary advertisement banners which load in DIV element called 'tb'.
How can I do this? I have done some googling and found an example using mshtml reference but I can't make it work from this example: https://stackoverflow.com/a/1218875
Any ideas?
Why wouldn't this work?
using System;
using mshtml;
using System.Windows.Forms;
namespace Client
{
public partial class Client : Form
{
public Client()
{
InitializeComponent();
HTMLDocumentClass htmldoc = wbBrowser.Document.DomDocument as HTMLDocumentClass;
IHTMLDOMNode node = htmldoc.getElementById("tb") as IHTMLDOMNode;
node.parentNode.removeChild(node);
}
}
}
I get an error:
'mshtml.HTMLDocumentClass' does not contain a definition for 'getElementById' and no extension method 'getElementById' accepting a first argument of type 'mshtml.HTMLDocumentClass' could be found (are you missing a using directive or an assembly reference?)
And:
Interop type 'mshtml.HTMLDocumentClass' cannot be embedded. Use the applicable interface instead.
You can do this using:
IHTMLDocument3 htmldoc = wbCtrl.Document.DomDocument as IHTMLDocument3;
IHTMLDOMNode node = htmldoc.getElementById("xBar") as IHTMLDOMNode;
node.parentNode.removeChild(node);
Related
I tried this.GameObject<SpriteRenderer>().sprite = spriteName; but it doesn't seem to work it just give me the error:
The type or namespace name 'sprite' could not be found (are you
missing a using directive or an assembly reference?)
public void TheBlueCircle()
{
this.GameObject.GetComponent<SpriteRenderer>().sprite = BlueCircle;
}
this.GameObjectis incorrect. You need to use the instance of GameObject and not the class so it will be this.gameObject.GetComponent<>()
In many cases, this.gameObject is not required, so you can probably just write GetComponent<>()
I added the HTML Agility Pack (HAP) to my solution using Nuget. My solution uses Silverlight 5. Some functions I can call from "using HtmlAgilityPack;" but some functions I cannot call. I need to get content of URL by following code lines:
string Url = "http://google.com.vn"; // this line is okay
HtmlWeb web = new HtmlWeb(); // this line is okay
HtmlDocument doc = web.Load(Url); // but this line is highlighted with an error 'Error HtmlAgilityPack.HtmlWeb' does not contain a definition for 'Load' and no extension method 'Load' accepting a first argument of type 'HtmlAgilityPack.HtmlWeb' could be found (are you missing a using directive or an assembly reference?)'
I solved my question
using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
using System.Windows;
using Microsoft.LightSwitch.Threading;
using HtmlAgilityPack;
namespace LightSwitchApplication
{
public partial class Table1ItemsListDetail
{
partial void Method_CanExecute(ref bool result)
{
// Write your code here.
}
partial void Method_Execute()
{
var wc = new HtmlWeb();
// string url = "http://www.nu.nl/feeds/rss/algemeen.rss";
wc.LoadAsync("http://google.com");
wc.LoadCompleted += new EventHandler<HtmlDocumentLoadCompleted>(DownloadCompleted);
//wc.
//
}
void DownloadCompleted(object sender, HtmlDocumentLoadCompleted e)
{
if (e.Error == null)
{
HtmlDocument doc = e.Document;
if (doc != null)
{
Dispatchers.Main.BeginInvoke(() =>
{
MessageBox.Show(doc.DocumentNode.Element("html").InnerHtml);
});
}
}
}
}
}
I'm using Farseer in my XNA project, but I have some trouble with the ContactListener. I created a class for my ContactListener but I always get these two error messages and I don't know how to fix the problems.
The type or namespace name 'ContactListener' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'ContactImpulse' could not be found (are you missing a using directive or an assembly reference?)
What is wrong with my ContactListener class?
class MyContactListener: ContactListener
{
void BeginContact(Contact contact)
{ /* handle begin event */ }
void EndContact(Contact contact)
{ /* handle end event */ }
void PreSolve(Contact contact, ref Manifold oldManifold)
{
Fixture fixtureA = contact.FixtureA;
Fixture fixtureB = contact.FixtureB;
if (fixtureB.CollisionCategories == Category.Cat10)
{
contact.Enabled = false;
}
}
void PostSolve(Contact contact, ref ContactImpulse impulse)
{ /* handle post-solve event */ }
}
Try this:
Open VS
Go to the Solution Explorer window
Search for a folder called References and right click it
Select Add Reference...
look for the Farseer assembly and add it
And try adding these in code:
using FarseerPhysics.Collision.Shapes;
using FarseerPhysics.Common;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Contacts;
using FarseerPhysics.Factories;
using FarseerPhysics.TestBed.Framework;
using Microsoft.Xna.Framework;
I am trying to show an instance of PluginManagerView with the below code.
This XAML file is in the same namespace, same project. But I got an error at the line of mainwindow.Show(); saying that
Error 1 'PluginManager.PluginManagerView' does not contain a definition for 'Show' and no extension method 'Show' accepting a first argument of type 'PluginManager.PluginManagerView' could be found (are you missing a using directive or an assembly reference?) Blah procedyre .cs 30 24 PluginManager
Can anyone tell me about what the problem is? And why doesn't it throw the error for the prior usages of MainWindow?
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.ComponentModel.Composition.Hosting;
namespace PluginManager
{
public class PublicProcedures : Application
{
public static void ShowPlugins()
{
var mainwindow = new PluginManagerView();
//An aggregate catalog that combines multiple catalogs
var catalog = new AggregateCatalog();
//Adds all the parts found in the same assembly as the Program class
//catalog.Catalogs.Add(new AssemblyCatalog(this.GetType().Assembly));
catalog.Catalogs.Add(new DirectoryCatalog("./Plugins/"));
var container = new CompositionContainer(catalog);
var modules = container.GetExportedValues<IPlugin>();
mainwindow.DataContext = modules;
mainwindow.Show();
}
}
}
In order to call Window.Show (which i guess is what you want to do), PluginManagerView would have to be derived from class Window, and its XAML would have to look somehow like this:
<Window x:Class="PluginManager.PluginManagerView" ...>
...
</Window>
It is complaining that whatever PluginManagerView is, it doesn't have a Show method (which you're trying to call in an instance of PluginManagerView called "mainwindow").
I have run into very strange problem:
I have made extension method for string like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Vaniv.Mvc
{
public static class StringHelpers
{
public static string ToSeoUrl(this string url)
{
// make the url lowercase
string encodedUrl = (url ?? "").ToLower();
System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9 -]");
encodedUrl = rgx.Replace(encodedUrl, "-");
return encodedUrl;
}
}
}
And problem that durning runstime I get error:
CS0246: The type or namespace name 'Regex' could not be found (are you missing a using directive or an assembly reference?)
Im not missing using directive. Nor do I missing Assembly (I can use Regex withing controller for example).
I have put my extension method into App_Code, but doubt it have any connection,
Move the cs file to another directory (out of App_Code folder) put it on the root of the project.
Check this article