|
I have a small app I wrote last year that opens 3 work-related web pages in separate tabs. Never had a moment's trouble until today. For no apparent reason the WebBrowser control no longer navigates. I get a "Navigation to web page was canceled" message. IE and FireFox are both working fine. Good strong Internet connection. If I set the WebBrowser to open in a new window, IE opens as expected and navigates to the proper page. My control's AllowNavigation property is still set to True.
The code below is from a test app I wrote to see if the problem was unique to my application, but it doesn't work either.
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
WebBrowser1.Navigate(txt.Text)
End Sub
If I change the Navigate statement to WebBrowser1.Navigate(txt.Text, True) it opens IE and goes to the desired page. Anyone have an idea? The program was working fine before and I've made no changes, so I'm a bit stumped.
|
|
|
|
|
|
I am using an HP, but the solutions offered from the search (both Google and Yahoo) were specific to a popup window displaying the "Navigation to the webpage was cancelled" message. Both IE and FF are working okay and the two tasks listed in the solutions are not present on my machine. Only the VS WebBrowser control is affected.
The only new thing I've done with VS lately is the addition to the toolbox of a 3rd party edit control (ScintillaNet). The control is not used in this project however and I can't imagine how it'd affect the WebBrowser (although my imagination is somewhat limited).
Stumped in Mississippi
|
|
|
|
|
Hi Alan,
I just experimented with a WebBrowser and it works as I would expect (Vista, IE7, .NET 2.0), e.g. navigating to "www.google.com".
Did you recently upgrade your IE (WebBrowser is or uses parts of IE)?
And does it fail on all kinds of URLs?
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Haven't upgraded lately. The WebBrowser fails with every url I try.
Also, the failure is immediate. There is no long pause as though it's trying to load (like with a weak WiFi signal). I get the "Canceled" message in 1 or 2 seconds.
Is it possible that the application can't connect for some reason?
|
|
|
|
|
Alan Burkhart wrote: Is it possible that the application can't connect for some reason?
I'm sure there is, but I'm not aware of any.
What is the exact symptom? are you getting an exception? if so, I suggest you look at Exception.ToString(), which shows all the available details (as opposed to Exception.Message).
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Not getting any exceptions. Just the browser message.
Using slightly different code in test app, and now the message is "This program cannot display the webpage."
Public Class Form1
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Try
WebBrowser1.Navigate("http://www.google.com/")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
txt.Text = WebBrowser1.Url.ToString
End Sub
End Class
|
|
|
|
|
Any chance you have a FireWall blocking your app completely?
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Found a suggestion: in IE(7) goto Tools/Internet Options/Advanced/ and uncheck "Show friendly HTML error messages", then try again to see the real problem.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Same result.
But... I just discovered that my Norton is shut down and won't run. Could be a related security issue. When I try to start Norton I get a little dialog thanking me for being a Norton BETA tester (never been one).
I'm off to grab the AVG freebie until I get Norton figured out. Perhaps the two problems have a common root? Stranger things have happened.
Will post back here when I'm done.
Thanks!
AB
|
|
|
|
|
It was Norton. The whole program was messed up and I had to reinstall. Now it's running fine, and the WebBrowser control is loading pages as it should.
Thanks so much for taking the time to help and have a great weekend when it gets here!
AB
|
|
|
|
|
You're welcome.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Hi All,
In our company we are making extensive use of the above mentioned component.
Because of the STA nature of this component we have many challenges in our code to fight threading issues related to this component. (and lots of other non-deterministic behaviour)
Does anybody know if there is a HTML Component available which is simular to the MSHTML component which is not based on this component. (or any other COM/PIA component)
Where looking for a true .NET component which can run safely within a MTA application.
Thanks for your time.
Extra info Component is both used in Windows and Web app
Groetjes,
Joost Verdaasdonk
modified on Thursday, September 17, 2009 11:05 AM
|
|
|
|
|
Hi All,
Good to see that I'm not the only one who finds this question hard to answer.
I'm still hoping on some lost component fullfilling my requirments.
If you know of one let me know.
Thanks.
Groetjes,
Joost Verdaasdonk
|
|
|
|
|
Thanks in adv.
how can we change the type of the control of Tool Strip like from button to Drop down button at run time
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
softdev_sup wrote: how can we change the type of the control of Tool Strip like from button to Drop down button at run time
Don't.
At least don't start with a ToolStripButton , make it a ToolStripDropDownButton from the start, and use the ShowDropDownArrow property to turn the dropdown functionality on and of as required.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
thanks for the post
but how can i add toolstripdropdown at run time , how to specofy that the type is dropdown or combobox or something else
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
How to: Add ToolStrip Items Dynamically - MSDN[^], will tell you how to do that.
softdev_sup wrote: how to specofy that the type is dropdown or combobox or something else
They are all separate classes, duplicate what is done in the tutorial given above and replace their control with one of your choosing. Take a look at the entry for ToolStrip on MSDN ToolStrip Control (Windows Forms) - MSDN[^]. There are loads of links on that page. Follow them in turn. Read the ones that are textual, code the ones that are examples (if you take my advice type the code in you learn far more that way, don't copy and paste it!).
The only real way to learn how to use the built in controls, is to research them properly. Start on MSDN, then google for more help on things you don't understand.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thank You so so much , GOD bless You
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
I work for a company that has developed a library for user authentication, and it uses this library for authenticating users that access the web site using Web Forms and ASP.NET. However, this isn't the focus of this post (or it would be obviously in the wrong place). For those who want to get to the point quickly, the real question is at the very end.
I have been tasked to create a Winforms C# application that also authenticates a user, and I am wanting to use this same library. I have installed the library locally, and it's working fine as in the following example:
private bool EncryptPassword(ref string PW)
{
Type Crypto;
object[] parameter = new object[1];
object CryptoObject;
try
{
Crypto= Type.GetTypeFromProgID("CCDUserLib.Crypto");
CryptoObject = Activator.CreateInstance(Crypto);
parameter[0] = PW;
object result = Crypto.InvokeMember("EncryptedPassword",
System.Reflection.BindingFlags.InvokeMethod, null,
CryptoObject, parameter);
PW = result.ToString();
return true;
}
catch
{
return false;
}
}
From what I understand, System.Type.GetTypeFromProgID("CCDUserLib.Crypto") searches the registry for the registered library "CCDUserLib". I am hoping that I don't have to install the CCD library locally, but instead reference the library that is already installed on our Web Server (which is not the workstation this software is going to be run on).
Is there any way to dynamically bind to a library that is installed on a different machine (like "\\CCDWebServer\bin\CCDUserLib.dll"), assuming the user has sufficient access rights to do so?
Thanks,
Daniel Bragg
|
|
|
|
|
You can't instantiate an object from a class that is not registered on the machine the code is running on. You also, cannot tell it where to find the class without the registration information in the registry.
You either have to install the library on the client workstation or you have to redesign the app to support creating the library objects on a remote server. That will introduce some performance, possibly licensing, and supportability issues, so that may not be the best course of action.
|
|
|
|
|
Thanks. Although licensing wouldn't be an issue (we wrote the library that we want to call), I don't believe it would be worth the effort to make it work this way. I'll just include the library in the distributables and call it done.
Daniel
|
|
|
|
|
Hi everybody,
When we use the Graphics object to draw, for example, on a Form, every time, something covers the entire or just a part of the Form (for example, another window) or when the Form is minimized and them maximized for example, all the drawn graphics are lost (or the part present on the covered part of the Form).
I wanted to know if there's anyway to retain these graphics in these cases? I don't (and can't) use the Paint method because I'm considering a case where the graphics are drawn using different method and not a single method to be called in the Paint event.
|
|
|
|
|
Hi,
this is a common question, for which I keep a standard reply, here it goes:
there are several steps to correctly draw something; it does not matter how complex the paint job is: from a single line, to a complex drawing, or a real work of art.
To make sure it all becomes visible on the screen and gets repainted automatically when moving, resizing, minimizing/maximizing/restoring or uncovering your Form, one should follow these steps:
1.
decide upon what object you want to draw; it normally is a Control (e.g. a Panel) or a Form itself. I prefer to add a Panel to a Form, then draw on the Panel. And I do not like PictureBoxes, they are pretty useless.
2.
create some variables (Rectangle, struct, class, whatever) that hold the parameters of your drawing. For a rectangle that could be top and left coordinate, and width+height, or just a Rectangle. etc. For a complex drawing, it could be a List of objects that derive of a common type, each having its own PaintMe() method.
3.
create a Paint handler (either add your own paint handler to the Paint event, or override the OnPaint method) for that Panel, and do all your drawing in there, using the Graphics object inside the PaintEventArgs, and your variables. Do not call CreateGraphics!
4.
if and when you want to change things, modify the variables and call Panel.Invalidate() or one of its overloads (for selective invalidation).
5.
If you want to animate things, perform the move (step 4) inside the Tick handler of a Windows.Forms.Timer which ticks on the GUI thread, so you are allowed to call Invalidate() from there too.
BTW: if you need to create some objects (Fonts, Pens, Brushes, ...) either keep them
alive in class members (hence create them only once); or create them inside the Paint
handler and don't forget to call Dispose() on them.
C# example:
private Panel panel;
private bool paintRectFlag=true;
private Rectangle rect=new Rectangle(20, 20, 300, 200);
private Pen rectPen=Pens.Black;
public Form1() {
InitializeComponents();
panel=new Panel();
panel.Bounds=new Rectangle(…);
panel.Paint+=panelPaintHandler;
Controls.Add(panel);
}
protected void panelPaintHandler(object sender, PaintEventArgs e) {
Graphics g=e.Graphics;
if (paintRectFlag) g.DrawRectangle(rectPen, rect);
}
protected void buttonClickHandler(object sender, EventArgs e) {
paintRectFlag=!paintRectFlag;
panel.Invalidate();
}
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Thank you soooo much for your detailed answer, but some questions: Can you please tell me:
1. Why do you find the PictureBox control a useless one?
2. Why did you say that we shouldn't call the CreateGraphics method?
3. What exactly does the Panel.Invalidate() method do and how it can be used here?
4. Why did you say that either create the pen, font, etc. object as class members or create them inside the Paint event handler and call the Dispose method? Why is the Dispose method necessary here and what's the difference between these two methods you mentioned.
Thank you in advance ...
|
|
|
|
|