Post by gabriel2564 on Oct 15, 2014 23:51:57 GMT 10
hello guys, I'm with a code that creates the favicon of a page , but there is a line in the code that gives you trouble ! It happens that I want to create a favicon for a website http : // or https : // . When I walk into a website http : // have the problem. How to rewrite this code ?
Code:
Dim web_request As System.Net.HttpWebRequest = System.Net.WebRequest.Create("http://" & WebControl1.Source.Host.ToString & "/favicon.ico")
Dim web_respone As System.Net.HttpWebResponse = web_request.GetResponse
Dim web_stream As System.IO.Stream = web_respone.GetResponseStream
Dim image As Image = image.FromStream(web_stream)
Form1.ImageList1.Images.Add(image)
Form1.TabControl1.SelectedTab.ImageIndex = Form1.ImageList1.Images.Count - 1
|
|
Post by Prezence on Oct 16, 2014 9:22:17 GMT 10
What is the full error?
Check out our website here. Check out AirBrowse here. Follow us on GitHub here.
|
|
Post by gabriel2564 on Oct 16, 2014 22:29:35 GMT 10
Well, THIS Problem in First Line : "highlight text "
|
|
Post by Prezence on Oct 17, 2014 0:25:10 GMT 10
Perhaps use a Try Catch statement around your code: You're probably getting the error because the favicon.ico file does not exist. Dim image As Image
Try Dim web_request As System.Net.HttpWebRequest = System.Net.WebRequest.Create("http://" & WebControl1.Source.Host.ToString & "/favicon.ico") Dim web_respone As System.Net.HttpWebResponse = web_request.GetResponse Dim web_stream As System.IO.Stream = web_respone.GetResponseStream image = image.FromStream(web_stream) Catch ex as Exception image = nothing 'or another image like a blank page icon etc. End Try
Form1.ImageList1.Images.Add(image) Form1.TabControl1.SelectedTab.ImageIndex = Form1.ImageList1.Images.Count - 1
Check out our website here. Check out AirBrowse here. Follow us on GitHub here.
Last Edit: Oct 17, 2014 0:26:06 GMT 10 by Prezence
|
|
Post by gabriel2564 on Oct 17, 2014 4:15:38 GMT 10
Well, the code STILL continues with problems , but I'll try to fix . Seizing the chance , I would ask why I can not run my browser on another PC ! I ALL I copy files from my debug folder , but when squeegee on another PC , it says that my program has stopped working . You know how to solve this problem Chris ?
|
|
Post by altair on Oct 17, 2014 5:49:02 GMT 10
Well, the code STILL continues with problems , but I'll try to fix . Seizing the chance , I would ask why I can not run my browser on another PC ! I ALL I copy files from my debug folder , but when squeegee on another PC , it says that my program has stopped working . You know how to solve this problem Chris ? Not sure without the 2 PC's Specs(Software). Could be .Net differences. Or something else. Cheers, Altair - The flying one
|
|
Post by gabriel2564 on Oct 17, 2014 7:49:40 GMT 10
The two computers have the latest version + of the framework (4.5 ) . Funny that other projects vb take this PC, my least ; . ( Any suggestions Tanks!
|
|
Post by gabriel2564 on Oct 17, 2014 7:53:59 GMT 10
Well, THIS Problem in First Line : "highlight text "
|
|