Need help with WebKit.NET

Can't get WebKit to work I get errors using thier own instructions

Page 1 of 1

4 Replies - 17979 Views - Last Post: 10 August 2010 - 02:47 AM Rate Topic: -----

#1 MrDot->"."  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-January 10

Need help with WebKit.NET

Post icon  Posted 15 January 2010 - 03:19 AM

I have Visual Studio fired up and am trying to get the Webkit.NET wrapper to work in a simple browser using VS 2008 C#.

I got VS to learn Vb not C# But there is so little code just to initialize the webkit engine I thought I would try it.. and Someone recently said when I thought I could mix C# and VB programs;

" Someone said:
Not quite.... Once you create a VB Project, all the code in that project needs to be VB. If you start a C# Project, the code needs to be C# (rumor has it that may change at some point in the future, but at the moment, you can't mix and match languages within a project.) BUT

What you CAN do, is within a SOLUTION mix and match your projects. So you could have a project with all your UI elements done in VB.NET, and then have a data access project that uses C#... it will all work very nicely. It is only within a single project that you can't mix languages. "


So I was hoping to start the browser in C# so it would work and then finish the browser in VB.. ( If Possible) -

Now.. this is the URL to webkit.NET's download and their instructions that are made for VS C# that I cannot get to work.

Webkit.NET home page with download: http://webkitdotnet....e.net/index.php

Webkit.NET Tutorial on how to set up the simple browser in Visual studio C#:
http://webkitdotnet....e.net/using.php

If you read through this tutorial you will see exactly what they tell me to do. I am copying and pasting this code in exactly and I am getting these errors right away.

Error 1 The name 'Form1_Load' does not exist in the current context

Error 2 The name 'webKitBrowser1_Navigated' does not exist in the current context

I have done exactly as they said.. placed the Bin folder on my C drive and told the toolbox to choose item webKitBrowser.dll and use that in the form.


Can anyone please follow this and see if you can figure out where I am going wrong?

EDIT: I thought a screenshot may be helpful. I should have thought of this earlier LOL.

First they tell me how to add the control:

" Lets begin by downloading the latest binary release of WebKit .NET from the project download page. Extract the contents of the included 'bin' folder to somewhere on your local machine, for example D:\webkitdotnet\bin.

Next, fire up Visual C# and create a new Windows Forms Application.

With the project created, you should be presented with a blank 'Form1' in the Windows Forms designer. To use the control in the designer, right click the toolbox and select Choose Items -> .NET Framework Components. Click 'Browse...', navigate to the WebKit .NET directory and select WebKitBrowser.dll.

Make sure the checkbox is ticked and click OK. Select the WebKitBrowser in the toolbox and drag it onto the empty form. In the properties window, change the 'Dock' property to 'Bottom' and resize the control leaving enough room at the top of the form for a navigation bar. "

Select a TextBox from the toolbox and drag it onto the top of the form, moving and resizing to suit. Do the same with a Button control. Change the 'Text' property of the button to '&Go!'

Here is what they tell me to do after adding the control.:
Posted Image

Here is my code:
Posted Image
End EDIT

Also, they do have a forum at sourceforge but it's rss feed based and I have no idea how to use it.. plus it has few threads and replies..

Someone is trying to make a VB version of the code so it will work in VB instead of C.. I can't seem to access this info - Does anyone think they could figure this out for me? It is only a few simple lines of code as you will see.

Edit: I am using Visual Studio 2008 Professional Edition.


Thanks!

This post has been edited by MrDot->".": 15 January 2010 - 03:38 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Need help with WebKit.NET

#2 janne_panne  Icon User is offline

  • WinRT Dev
  • member icon

Reputation: 429
  • View blog
  • Posts: 1,047
  • Joined: 09-June 09

Re: Need help with WebKit.NET

Posted 15 January 2010 - 07:25 AM

Look at the tutorial, the last part of it:

//Add the following event handlers. When the form is loaded, we set the
//browser to display an obligitory 'Hello World' message. When the 
//browser navigates to a new page, we update the contents of the textbox
//to reflect the new location:
void Form1_Load(object sender, EventArgs e)
{
	webKitBrowser1.DocumentText =
		"<h1><a href=\"http://google.com\">Hello, World!</a></h1>";
}

void webKitBrowser1_Navigated(object sender, 
	WebBrowserNavigatedEventArgs e)
{
	textBox1.Text = webKitBrowser1.Url.ToString();
}



You haven't copy-pasted that yet into your Form1 class.
Was This Post Helpful? 0
  • +
  • -

#3 MrDot->"."  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-January 10

Re: Need help with WebKit.NET

Posted 15 January 2010 - 07:54 AM

View Postjanne_panne, on 15 Jan, 2010 - 06:25 AM, said:

Look at the tutorial, the last part of it:

//Add the following event handlers. When the form is loaded, we set the
//browser to display an obligitory 'Hello World' message. When the 
//browser navigates to a new page, we update the contents of the textbox
//to reflect the new location:
void Form1_Load(object sender, EventArgs e)
{
	webKitBrowser1.DocumentText =
		"<h1><a href=\"http://google.com\">Hello, World!</a></h1>";
}

void webKitBrowser1_Navigated(object sender, 
	WebBrowserNavigatedEventArgs e)
{
	textBox1.Text = webKitBrowser1.Url.ToString();
}



You haven't copy-pasted that yet into your Form1 class.



Thanks.. but I have tried that too. I just didn't mention it in my last post because I thought if I could figure out the errors of 1 and 2 the rest would fall into line.

Now my code looks like this:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WebKitTest2
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
			this.Load += new EventHandler(Form1_Load)
			this.webKitBrowser1.Navigated += 
				new WebBrowserNavigatedEventHandler(webKitBrowser1_Navigated); 

		}

		private void button1_Click(object sender, EventArgs e)
			webKitBrowser1.Navigate(textBox1.Text); 
		{

		}
	}
}
void Form1_Load(object sender, EventArgs e)
{
	webKitBrowser1.DocumentText =
		"<h1><a href=\"http://google.com\">Hello, World!</a></h1>";
}

void webKitBrowser1_Navigated(object sender,
	WebBrowserNavigatedEventArgs e)
{
	textBox1.Text = webKitBrowser1.Url.ToString();
}


And I get these errors:

1 Object reference not set to an instance of an object.
2 ; expected
3 Invalid token '(' in class, struct, or interface member declaration
4 Invalid token ')' in class, struct, or interface member declaration
5 A namespace does not directly contain members such as fields or methods
6 ; expected
7 The name 'Form1_Load' does not exist in the current context
8 The name 'webKitBrowser1_Navigated' does not exist in the current context

Is my problem the formatting.. am I not putting the copy paste in the correct place? So far the book I am learning VB on does not cover copying and pasting code from other sources. ( I assume the format would be the same in C# because Virtual Studio is the same tool used for both VB and C#)

This post has been edited by MrDot->".": 15 January 2010 - 07:56 AM

Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,515
  • Joined: 23-August 08

Re: Need help with WebKit.NET

Posted 15 January 2010 - 07:56 AM

InitializeComponent();
this.Load += new EventHandler(Form1_Load)


Re error #2...learn to read your errors. Look closely at the above.

EDIT:
And your other two functions are not defined in your class, they're outside of it.
Was This Post Helpful? 0
  • +
  • -

#5 Guest_arijit.gnit@gmail.com*


Reputation:

Re: Need help with WebKit.NET

Posted 10 August 2010 - 02:47 AM

View PostMrDot->, on 15 January 2010 - 02:19 AM, said:

I have Visual Studio fired up and am trying to get the Webkit.NET wrapper to work in a simple browser using VS 2008 C#.

I got VS to learn Vb not C# But there is so little code just to initialize the webkit engine I thought I would try it.. and Someone recently said when I thought I could mix C# and VB programs;

" Someone said:
Not quite.... Once you create a VB Project, all the code in that project needs to be VB. If you start a C# Project, the code needs to be C# (rumor has it that may change at some point in the future, but at the moment, you can't mix and match languages within a project.) BUT

What you CAN do, is within a SOLUTION mix and match your projects. So you could have a project with all your UI elements done in VB.NET, and then have a data access project that uses C#... it will all work very nicely. It is only within a single project that you can't mix languages. "


So I was hoping to start the browser in C# so it would work and then finish the browser in VB.. ( If Possible) -

Now.. this is the URL to webkit.NET's download and their instructions that are made for VS C# that I cannot get to work.

Webkit.NET home page with download: http://webkitdotnet....e.net/index.php

Webkit.NET Tutorial on how to set up the simple browser in Visual studio C#:
http://webkitdotnet....e.net/using.php

If you read through this tutorial you will see exactly what they tell me to do. I am copying and pasting this code in exactly and I am getting these errors right away.

Error 1 The name 'Form1_Load' does not exist in the current context

Error 2 The name 'webKitBrowser1_Navigated' does not exist in the current context

I have done exactly as they said.. placed the Bin folder on my C drive and told the toolbox to choose item webKitBrowser.dll and use that in the form.


Can anyone please follow this and see if you can figure out where I am going wrong?

EDIT: I thought a screenshot may be helpful. I should have thought of this earlier LOL.

First they tell me how to add the control:

" Lets begin by downloading the latest binary release of WebKit .NET from the project download page. Extract the contents of the included 'bin' folder to somewhere on your local machine, for example D:\webkitdotnet\bin.

Next, fire up Visual C# and create a new Windows Forms Application.

With the project created, you should be presented with a blank 'Form1' in the Windows Forms designer. To use the control in the designer, right click the toolbox and select Choose Items -> .NET Framework Components. Click 'Browse...', navigate to the WebKit .NET directory and select WebKitBrowser.dll.

Make sure the checkbox is ticked and click OK. Select the WebKitBrowser in the toolbox and drag it onto the empty form. In the properties window, change the 'Dock' property to 'Bottom' and resize the control leaving enough room at the top of the form for a navigation bar. "

Select a TextBox from the toolbox and drag it onto the top of the form, moving and resizing to suit. Do the same with a Button control. Change the 'Text' property of the button to '&Go!'

Here is what they tell me to do after adding the control.:
Posted Image

Here is my code:
Posted Image
End EDIT

Also, they do have a forum at sourceforge but it's rss feed based and I have no idea how to use it.. plus it has few threads and replies..

Someone is trying to make a VB version of the code so it will work in VB instead of C.. I can't seem to access this info - Does anyone think they could figure this out for me? It is only a few simple lines of code as you will see.

Edit: I am using Visual Studio 2008 Professional Edition.


Thanks!


to remove this error you need to do ----------

1. in design mode {Ex: Form1.cs[Design]} double click on the form
2. double click on webkitbrowser 's Navigated event in the properties window under the Events tab

.
.
Posted Image
Was This Post Helpful? 0

Page 1 of 1