.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

webBrowser exception problem

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :Windows Application

I'm writing a C# program that makes use of the webBrowser control. Generally I've been successful in using it but have encountered a problem I can't figure out.

I intercept the DocumentCompleted event from my webBrowser control. During the processing of that event I create an additional webBrowser control and  call its Navigate function to tell it to navigate to a specific URL. When I do that it throws an exception : "IWebBrowser2 get from the native ActiveX control did not succeed", and I can see that the axIWebBrowser2 property of the control is null.

My code is approximately like this:

webBrowser otherWebBrowser = new webBrowser(); 

private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
   MessageBox.Show("Excption was thrown!");

Is it possible that you can't instantiate and call the Navigate method for a webBrowser

View Complete Post

More Related Resource Links

OutOfMemory Exception on 64 bit machines (Interop Problem)

Hello Our application needs to display the printer settings dialog. This works fine in 32bit windows systems, but results in a System.OutOfMemoryException at System.Runtime.InteropServices.Marshal.AllocHGlobal(IntPtr cb) when it is running under 64bit (Windows 2008 Server). The problem can easily be reproduced in a winform app. You need to set the platform target to x86 to experience the problem.Unfortuantely, our application needs to be built fox x86 for other reasons. Any ideas why this happens? Kind Regards Mat Source Code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Printing; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication8 {     public partial class Form1 : Form     {         [DllImport("kernel32.dll")]         static extern IntPtr GlobalLock(IntPtr hMem);         [DllImport("kernel32.dll")]         [return: MarshalAs(UnmanagedType.Bool)]         static extern bool GlobalUnlock(IntPtr hMem);         [DllImport("kernel32.dll")]   &n

Soap exception problem

Hello, I'm having a problem with the web service soap exception that im facing. In my if else statement, the web service keeps on throwing soap exception when name was not found. SoapException was caught A user with the account name test.name could not be found --> User Not Found: Could not load profile data from the database. My question is.. Is it possible to handle that in if else statement? Basically the web service returns profile data (ex. name, age, address, in xml format) What i want is if just like this.. If _result isnot nothing then _str = _result else 'do nothing end if Is that possible?    Ã‚®Â©T½¼

WCF: Problem throwing FaultException after touching Exception.Data collection



My client code receives a CommunicationException if my server code touches the Exception.Data collection.  If my server code avoids the Exception.Data collection, then my client code works (i.e. it receives my custom exception as expected). 


I have reduced this problem down to two simple examples (see below)..one that works (A), one that does not (B).  The only difference between the two examples is that in example B, the code looks at the Exception.Data.Count property.


Why would touching the Exception.Data collection cause my client code to receive the CommunicationException? 

Is there any way to avoid this?


Thank you in advance for an consideration you may give to this question. 


A: Working Example: Client Receives CustomException
  throw new CustomException("This is a custom exception.");
 catch (CustomException ex)
  throw new FaultException<CustomException>(ex, new FaultReason(ex.Message), new FaultCode("Receiver"));


B: Non-working Example: Clien

How to remove .NET Remoting Fatal problem :Exception



I am implementing Publisher/Subscriber pattern via .NET Remoting. My publisher is waiting for incoming requests on its url. At its side remoting environment configures properly and no problem at all.

At subscriber's end when I make some subscriptions from its side to publisher, it hangs out. I mean program hangs and console shows nothing , and it gone away, no exception here. When I disconnect publisher it now it resume's and follow processing and throws exceptions with stack Trace:

Will try again to add a subscription.System.Net.Sockets.SocketException (0x80004

005): An existing connection was forcibly closed by the remote host


Server stack trace:

   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size,

 SocketFlags socketFlags)

   at System.Runtime.Remoting.Channels.SocketStream.Read(Byte[] buffer, Int32 of

fset, Int32 size)

   at System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[] buffe

r, Int32 offset, Int32 count)

Webbrowser viewing page problem.


I've made a webrowser form.

And it all works fine but, there is a certain website that gets all screwy when it is viewed in a webbrowser. It prob is the way the website was made. Would there be anything I can do for the webbrowser?

Here is a picture of them.


This first one see how there are some things behind it.



This second one when I click on an section it shows it was clicked a little bit above.



This third one some times when I click on a section everything disappears completely but the sections.



This fourth one there are like private messages, user cp, and all that. It is not even supose to be near where it is now.

It is suppose to be way at top of entire section.



Anyone know how to fix this without fixing the website?



Every self-respected programmer should include exception handling techniques. Sometimes your application will generate an error. Regardless of who was responsible for this error, the programmer or the user, it is up to the first to include the necessary exception handling techniques to keep his/her program from crashing. The .Net environment provides useful techniques for avoiding disastrous errors such as try-catch statements and user-defined exceptions.

Global Exception Handling with ASP.NET

After your global exception handler has done its work, you'll want to redirect the users of your website to a friendly page that tells them that something has gone wrong, and then provide them with customer support information as well as a link back to your web application's home page.

Problem to group radio button across gridview rows

In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

Regrading Sharpoint 2010 problem and solutions

We can write your question and problem on this blogger.you get ans.use.

This sharpoint 2010 problem solving threads

Hi friend,

you can use this thread to solving problem and solutions.

SQL Server 2005 Try and Catch Exception Handling

I'm pretty excited to see that there is some real error handling for T-SQL code in SQL Server 2005. It's pretty painful to have your wonderfully architected .NET solution tainted by less-than-VBScript error handling for stored procedures in the database. The big difference being the addition of TRY..CATCH blocks. Let's take a look:

Virtual Path Problem


 I get the following error on last line below (working on remote host): 'E:\web\sfcascom\ls_admin/uploads/images/001.JPG' is not a valid virtual path,

Note that the slashes go in different directions

I've tried a number of things but nothing seems to work. Thanks-


Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Web.UI.WebControls

Imports System.Drawing.Imaging.ImageCodecInfo
Partial Class Protected_imageupload
    Inherits System.Web.UI.Page
    Private Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        ' Initialize variables
        Dim sSavePath As String
        Dim sThumbExtension As String
        Dim intThumbWidth As Integer
        Dim intThumbHeight As Integer
        Dim sFilename As String = ""
        ' Set constant values
        'sSavePath = "images/"
        sSavePath = Server.MapPath("~/") + "ls_admin/uploads/images/"

        sThumbExtension = "_thumb"
        intThumbWidth = 160
        intThumbHeight = 120

        ' If file field isn?t empty
        If FilUpload.PostedFile IsNot Nothing Then
            ' Check file size (mustn?t be 0)
            Dim myFile As Http

Strange Photo upload problem


I'm working project it's live on shared hosting

we'er uploading photos to a file on the server everything works fine the photo is resized renamed and sent to the folder

the upload page returns the thumbnail and the full size photo it's there all the photos have to be approved by an admin

twice now after they have been approved they disapear I checked the folder they are not there could there be anywhere

on the server they could get hung up before they go into the folder I have it setup so when you delete the data base entry it deletes the photo from the folder othe than that you need to open the folder and delete the photo this has hapened twice now I tried to recreate it with no luck

thaks for your help in advance

ASP.Net Caching problem ??


I'm having a problem with an asp.net 3.0 application using a gridview to display data.  The problem seems to be that despite a brand new .selectCommand being sent to the sqlDataSource, the gridview starts displaying data from *someone else's* query.  For example, user A is logged in and will be working fine until a few page submissions later when the gridview data starts suddenly showing information that belongs to another user. 

This is my first asp.net application, though I've been working with classic asp and ADO for years so I'm used to sending a SQL string and getting back the results from that string.  Apparently there is a complex caching system which is interferring which I do not at all understand so at this point I just want to stop the server from caching any data whatsoever.  Is this possible?

Any and all help will be much appreciated!!

Could some one tell me whats the Problem with this String Manipulation ??? C#.net



I store some values from code behind to a label which is Hidden !

<asp:Label ID="lbl_Hidden" runat="server" Visible = "false"></asp:Label>

and at the page load event i retrieve the value of the label & assign it to a string !

stringvalue = lbl_Hidden.Text;

Now i dont know why this manipulation does'nt work !

I've a character 'A' in the string and i'm unable to replace it with a space !

stringvalue.Replace(A, " ");

Wot do u think abt it ????

RaiseEvent problem


I have a parent page ProdView.aspx and two static UserControls, UC1 and UC2. Each UC is in an Ajax accordion pane and the accordion inside an updatepanel.

UC1 has a Gridview footer with couple of textboxes and a link button that fires an Add Row insert procedure. I want to Raise an event that will rebind the UC2 after the row insert in UC1.

First I created the sub delegate and event in UC1:

  • Public Delegate Sub MyRefresh(ByVal sender As Object, ByVal e As CommandEventArgs)
  • Public Event Refresh_UC1 As MyRefresh

In the same UC1 the Insert procedure that fires the insert and RaiseEvent:

Sub PricingGrid_Insert(ByVal sender As System.Object, ByVal e As EventArgs)
       Dim myConn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString)
       Dim myCom As SqlCommand = New SqlCommand("AddRow", myConn)
       myCom.CommandText = "AddRow"
       myCom.CommandType = CommandType.StoredProcedure


Gridview Enable Selection Problem



I have a gridview with Enable selection and Enable Paging equals to TRUE.

I also set the PageSize of my gridview to 4 so that I only displays 4 rows per page.

The problem is when I click the pager in the bottom of my gridview, my gridview is disappearing and no records appear.

Here is code behind of my gridview:

If e.Row.RowType = DataControlRowType.DataRow Then
                e.Row.Attributes("style") = "cursor:pointer"

                e.Row.Cells(2).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(3).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(4).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(5).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(6).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend