473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

System.NullReferenceException at SetClientSite / IOleObject

Hi!

I want to create a WebBrowser Control at runtime. So i ported the "at
start creation" of the Control to a new routine.

Everything works fine, but i implement the BeforeNavigateFix and a own
Content Menu. For this i need this lines:
public void create_new_browser()
{

AxSHDocVw.AxWebBrowser AxWebBrowser1 = new AxSHDocVw.AxWebBrowser();

// Here is the code for adding the control to the form
// ...
// ...

object obj = AxWebBrowser1.GetOcx();

IOleObject oc = obj as IOleObject;

oc.SetClientSite(this); // System.NullReferenceException

// Fix for OnBeforeNavigate .Net 1.0

ie_events = (SHDocVw.WebBrowserClass) Marshal.CreateWrapperOfType
(AxWebBrowser1.GetOcx(), typeof(SHDocVw.WebBrowserClass));

SHDocVw.DWebBrowserEvents_BeforeNavigateEventHandl er BeforeNavigateE =
new SHDocVw.DWebBrowserEvents_BeforeNavigateEventHandl er
(OnBeforeNavigate);

ie_events.BeforeNavigate +=
BeforeNavigateE;//System.NullReferenceException

}
If i Comment the both lines with // System.NullRefernceException it
runs, but with no BeforeNavigate Event, and not with the content menu -
which worked fine before creating it at runtime.

I tried several things, but running out of ideas and found nothing with
google :(

All it throws out is a System.NullReferenceException and that the object
ist not bound to the instance.

Maybe someone has done this before or can me give some hints.

Thanks for your Help

Matt
Nov 15 '05 #1
0 2667

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in...
1
by: Rafael | last post by:
Hi, I hope I can find some help for this problem IDE: Visual Studio.NET 2003 Developer Editio Language: C# Problem: "An unhandled exception of type 'System.NullReferenceException' occurred in...
7
by: mike p. | last post by:
I have a docbook xml file, and am using standard docbook 1.61.3 xsl stylesheets to do xhtml transform. Transform works fine when using MSXML. When I try to do the following using asp.net 1.1: ...
2
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item...
1
by: msnews.microsoft.com | last post by:
I'm trying to fill an array of objects but when I add the first object I get a NullReferenceException. ----------------------------------------------------------------------------...
2
by: sxiao | last post by:
Hi, there I got a NullReferenceException when there are more than one users trying to open the same page at the same time. The senerio is: Two users logged into the web application using the...
6
by: William Mild | last post by:
I must be getting brain fried. I can't see the error. Create a new web form with the following code begind: Public Class test Inherits System.Web.UI.Page Public Class ReportCardData ...
3
by: Alex J. | last post by:
I just started to learn C# (my background is in C++), and right now I study the sockets, TCP/IP etc... so, I found a usefull source code at:...
0
by: radek08 | last post by:
Hi, Im writing a Function to show tooltips for all containers in a ActiveX Control. Any suggestions upon how to get the size of a IOleObject? Tried to get the Top,Left,Width and Height property,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.