I have a problem to set up the Browser (CefSharp) language for my application.
So in my Initialization config I already configure it to set the Local Language to German:
Public Sub InitializeChromium()
Dim settings As New CefSettings()
settings.Locale = "de-DE"
If Not IO.Directory.Exists(_cachePath) Then IO.Directory.CreateDirectory(_cachePath)
settings.PersistSessionCookies = True
settings.CachePath = _cachePath
CefSharp.Cef.Initialize(settings)
browser = New ChromiumWebBrowser(address:=lblWEBSiteURL.Text)
pnlBrowser.Controls.Add(browser)
browser.Dock = DockStyle.Fill
End Sub
The strange thing is that when I am starting the application as my project directly in Visual Studio everything works fine. And the pages load with the German preference language. But when I install the same application on the same PC, the pages are loading in English language.
I have tried to set:
settings.Locale = "de"
settings.AcceptLanguageList = "de,de-DE"
and also inserted the Local de.pak (language pak) in my application but still when I install it, it is always on English.
Do you have any suggestions or tips?
Related
I have a situation in which I have a aspx page ,that hit on schedule ,all my logic is written in this page.I want that while this page is hit on schedule time,no console window or page that was hit,will not show up.what I have done to hide console window ,
1.just change it to window application output in application setting.
2.and to start aspx page
Dim url As String = ""
url = ConfigurationManager.AppSettings("www.youtube.com")
Process.Start(url)
But Problem is when that page is hit using this code ,that page open up in browser?
if you any logic written in web page code behind that you need to execute from many places, ideally you should move that to a common library project accessible to all other projects.
I am not much clear why we need to execute a web page from console, still you can use WebRequest and WebResponse classes to get the output of the web page without opening in browser.
Dim _request As WebRequest = WebRequest.Create("www.youtube.com")
_request.GetResponse()
Old Answer
using _response As WebResponse = _request.GetResponse()
Using _reader As New StreamReader(_response.GetResponseStream())
Dim _html As String = _reader.ReadToEnd()
End Using
End Using
here is a simple code to run a page without open it in browser.
Dim url As String = ""
url = ConfigurationManager.AppSettings("url")
Dim client As New WebClient
client.DownloadString(url)
client.Dispose()
Through Windows app i want to login into website using webcontrol automatically and i need to search and browse the web pages .. here is my eg:
In load event
Dim webAddress As String = "http:XXXXXXXx"
' WebControl2.WebView.Url = webAddress
WebControl2.WebView.LoadUrlAndWait(webAddress)
WebControl2.WebView.EvalScript("document.getElementsByName('username')[0].value = 'xxxxxx';")
WebControl2.WebView.EvalScript("document.getElementsByName('password')[0].value = 'yyyyy';")
WebControl2.WebView.EvalScript("document.getElementsByName('username')[0].focus();")
WebControl2.WebView.EvalScript("document.getElementsByName('password')[0].focus();")
WebControl2.WebView.SetFocus()
WebControl2.WebView.EvalScript("document.getElementByInputType('submit')[0].click();")
SendKeys.Send("{TAB}")
SendKeys.Send(ControlChars.Cr)
it works fine but i could't access the page which i have loged in
I've read bunch of Q&As but none helped me.
I'm using VB.net; added awesomium browser control on the form. I need to be able to change its proxy server on the fly (example: User clicks a button to change proxy IP & port). Would it be possible? If not maybe I could create a dynamic awesomium browser control and than add it to the form (also on button click). But still don't know how to initialize control with the proxy.
If I cannot change it while running that is fine. Can I read proxy from some file and than initialize control with that proxy?
Nevermind - below worked for me:
Dim prefs As WebPreferences = New WebPreferences()
prefs.ProxyConfig = txtProxy.Text
Dim session As WebSession = WebCore.CreateWebSession(prefs)
Dim webcontrol As WebControl = New WebControl()
webcontrol.WebSession = session
Me.panWeb.Controls.Add(webcontrol)
webcontrol.Dock = DockStyle.Fill
webcontrol.Source = New Uri(txtURL.Text)
webcontrol.Visible = True
Currently I'm new to this and I'm attempting to get this all to work, right now I've looked into and made a module which allows to me to change the user-agent of the internal web-browser so I can manipulate it easily however this is where the issue lies.
I'm assuming I must be editing the auto generated code because the file itself is called "Form1.Designer.vb" and I have no idea where to start putting in custom code to override the current code such as I wanting to do something like this;
Me.WebSiteBrowser1.Dock = System.Windows.Forms.DockStyle.Fill
Me.WebSiteBrowser1.Location = New System.Drawing.Point(3, 3)
Me.WebSiteBrowser1.MinimumSize = New System.Drawing.Size(20, 20)
Me.WebSiteBrowser1.Name = "WebSiteBrowser1"
Me.WebSiteBrowser1.Size = New System.Drawing.Size(671, 413)
Me.WebSiteBrowser1.TabIndex = 0
ChangeUserAgent("This is after the url agent gets changed after the first url open")
Me.WebSiteBrowser1.Navigate("http://www.whatsmyuseragent.com/", Nothing, Nothing, "User-Agent: This is the first open url agent")
However whenever I change anything in the visual template it automatically resets back to
Me.WebSiteBrowser1.Dock = System.Windows.Forms.DockStyle.Fill
Me.WebSiteBrowser1.Location = New System.Drawing.Point(3, 3)
Me.WebSiteBrowser1.MinimumSize = New System.Drawing.Size(20, 20)
Me.WebSiteBrowser1.Name = "WebSiteBrowser1"
Me.WebSiteBrowser1.Size = New System.Drawing.Size(671, 413)
Me.WebSiteBrowser1.TabIndex = 0
So my question is where do I write the custom code that would allow me to keep that after the auto-generation from the visual creator?
You should be putting your code in the form1.vb and leave the designer file alone. In the form1.vb[Design] you can change the properties in the properties window. If it is not currently docked to the right side of the VS designer you can show it by going to the Menu -> View -> Properties Window and select it.
I'm deploying an application built with VS 2010 Express edition via ClickOnce.
I have associated some file extensions using the options provided in the Publish section of the project's properties.
When I install the application, the associated file extension icons appear normally in Explorer but, when the user tries to open a file in my application, the associated icons appear blank.
The relative code section is the following:
Dim dialog As New OpenFileDialog
With dialog
.AddExtension = True
.CheckFileExists = True
.CheckPathExists = True
.DefaultExt = "pss"
.FileName = String.Empty
.Filter = "Data files|*.pss|All files (*.*)|*.*"
.FilterIndex = 0
.InitialDirectory = MySettings.SavePath
.Multiselect = False
.ValidateNames = True
If .ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
OpenFile(.FileName)
End If
End With
I was always under the impression that OpenFileDialog is a wrapper for Explorer, but for some reason the icons don't appear correct.
Does anyone have any idea how to correct the problem?
Edit: The behaviour is only relevant to Windows 7. Windows XP behaves normally.
I believe you need to set the default view to thumbnail, so that the graphics appear for the pss files. You can check this by manually changing the view to thumbnail while running your application.
If changing the view to thumbnail shows the graphics then check the link below to achieve this:
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/571b39c2-0edf-4159-ac8d-1c059f69a978
I forgot to change the included associated icons to:
Build action: Content
Copy to Output Directory: Always
I found this thanks to the manual updates, during which I was getting the error message "Object Reference not set to an instance of an object" during the updateCompleted event.