I have a Windows VB application developed in Visual Studio 2013 that incorporates a CefSharp Chromium web browser (version 86.0.241 using the NuGet packages). Target CPU is set to x86, the build output path is set to bin\x86\debug, Configuration is set to Active (debug) and the Platform is set to Active (x86). The web browser works great on the development machine, but when I deploy the app to the target machine (which is a server), the browser displays a blank screen and freezes.
The CefSharp support files are included in the deployment package (InnoSetup), but I'm confused on which version of VC++ redistributables I need to deploy.The CefSharp FAQ's state that with versions 65.0.0 and above, the minimum of VC++2015 needs to be deployed. I had the client install this version on the target machine (when I originally deployed this app, I did not include the VC++ redistributables), but the browser still does not work. Do I need to deploy a different version?
Any other ideas on what I'm doing wrong? Please help!
Larry
Here is a link to the .zip file containing the CEF debug.log files from the client's three servers (the three servers rotate based on demand):
https://www.dropbox.com/s/b3zjxxk79v9xl9b/DataMinerDebugLogs.zip?dl=0
Please let me know if any of these provides the reason why the Chromium browser is displaying only a blank page.
Thanks.
Details of the log entry mentioned in my last comment:
[1228/093028.760:INFO:CONSOLE(32)] "Refused to connect to 'https://collection.decibelinsight.net/i/13878/265573/c.json' because it violates the following Content Security Policy directive: "connect-src https://qbonline.api.intuit.net https://cdn.decibelinsight.net https://api.segment.io 'self' https://.intuit.com https://.intuit.com:* https://.intuitcdn.net: https://hosted-shell-assets-us-west-2.s3.us-west-2.amazonaws.com wss://plugin-localhost.intuitcdn.net:* wss://plugin.intuitcdn.net:* https://.intuit.net wss://.msg.liveperson.net/ws_api/account/ https://*.objectstorage.liveperson.net/ https://scripts.neuro-id.com https://api.neuro-id.com https://logs.neuro-id.com".
", source: https://cdn.decibelinsight.net/i/13878/265573/di.js (32)
Code from Auth Class (the form that opens and displays the Chromium browser):
Imports Intuit.Ipp.OAuth2PlatformClient
Imports System.Net
Imports System.IO
Imports System.Web
Imports CefSharp
Imports CefSharp.WinForms
Public Class Auth
Public WithEvents Browser As ChromiumWebBrowser
Dim Settings As New CefSettings
Private Sub Auth_Load(sender As Object, e As EventArgs) Handles MyBase.Load
oauthClient = New OAuth2Client(ClientID, ClientSecret, RedirectURL, "production")
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Dim scopes As List(Of OidcScopes) = New List(Of OidcScopes)()
scopes.Add(OidcScopes.Accounting)
authorizeURL = oauthClient.GetAuthorizationURL(scopes)
Settings.CefCommandLineArgs.Add("disable-gpu")
Browser = New ChromiumWebBrowser(authorizeURL)
Me.Controls.Add(Browser)
Browser.Dock = DockStyle.Fill
End Sub
Private Sub Browser_AddressChanged(sender As Object, e As AddressChangedEventArgs) Handles Browser.AddressChanged
Dim Str As String = Browser.Address
If InStr(Str, "&realmID", CompareMethod.Text) Then
Dim q = HttpUtility.ParseQueryString(Browser.Address)
Dim Code As String = ""
Dim RealmID As String = ""
For Each key In q.Keys
If InStr(key, "code") Then
Code = q.Item(key)
ElseIf InStr(key, "realmId", CompareMethod.Text) Then
RealmID = q.Item(key)
End If
Next
Call GetAuthTokens(Code, RealmID)
End If
End Sub
End Class
The "Address_Changed" event can be ignored and the first 5 lines of the "Load" event all relate to another SDK used in the app, none of which is related to the Chromium browser.
Startup code added:
Shared Sub Main()
'This sub executes first.
Dim Settings As New CefSettings
Settings.CefCommandLineArgs.Add("disable-gpu")
cef.initialize(Settings)
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New MainMenu)
End Sub
Related
I am trying to write a VB.Net script to download a file from the web in a SSIS dtsx package.
I started from this, but I am having only proxy authentication errors (error 407).
I double checked the proxy, the port and the URL an they are right!
Can anyone help me please? I can't understand where the problem could be.
' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Net
Public Class ScriptMain
Public Sub Main()
Dim objWebClient As WebClient = New WebClient()
Dim objCache As New CredentialCache()
Dim strDownloadURL As String = "http://www.example.com/data.xlsx"
Dim strProxyURL As String = "myproxy.mycompany.local"
Dim intProxyPort As Integer = 1234
'Set Proxy & Credentials as a Network Domain User acc to get through the Proxy
Dim wp As WebProxy = New WebProxy(strProxyURL, intProxyPort)
objWebClient.Proxy = wp
'Download file, use Flat File Connectionstring to save the file
objWebClient.DownloadFile(strDownloadURL, "E:\MyFile.xlsx")
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
The file of strDownloadURL is accessible by browser and doesn't need any form of authentication. Anyone can access it by a web browser.
I'm trying to implement this code:
Dim result As MessageBoxResult = _
MessageBox.Show("Would you like to see the simple version?", _
"MessageBox Example", MessageBoxButton.OKCancel)
If (result = MessageBoxResult.OK) Then
MessageBox.Show("No caption, one button.")
End If
But getting an error: Type 'MessageBoxResult' is not defined
Why is happening?
I'm using: Microsoft Visual Studio Professional 2013 Version 12.0.30501.00 Update 2 Microsoft .NET Framework Version 4.5.51641
Nothing wrong with your code. It should work (I implemented it myself). So it has to be some linking error / install error / or project creation error.
So lets fix, so lets try this:
File -> New -> Project
Select Template -> Visual Basic -> Store App -> windows Phone App -> Blank App (Windows Phone Silverlight)
Select 8.0 as the Target
It should generate you a blank app, then lets try and create a MessageBox on the Page Loaded Event
Imports System
Imports System.Threading
Imports System.Windows.Controls
Imports Microsoft.Phone.Controls
Imports Microsoft.Phone.Shell
Imports System.Windows
Partial Public Class MainPage
Inherits PhoneApplicationPage
' Constructor
Public Sub New()
InitializeComponent()
SupportedOrientations = SupportedPageOrientation.Portrait Or SupportedPageOrientation.Landscape
End Sub
Private Sub PhoneApplicationPage_Loaded(sender As Object, e As RoutedEventArgs)
Dim result As MessageBoxResult = _
MessageBox.Show("Would you like to see the simple version?", _
"MessageBox Example", MessageBoxButton.OKCancel)
If (result = MessageBoxResult.OK) Then
' Do whatever
End If
End Sub
End Class
If that doesn't work then we need to make sure that System.Windows is imported
Right click on the Project -> Properties
Click on References
Make sure System.Windows has a checkmark
If System.Windows didn't resolve then you had a Windows Phone Runtime app (targetting Windows Phone 8.1) rather than a Windows Phone Silverlight app (for either 8.0 or 8.1). Chubosaurus' steps will create a Silverlight app.
You can confirm in the Solution Explorer, which will show the target for the project. To use System.Windows and MessageBox you will need a Windows Phone Silverlight app.
If you have a Windows Phone 8.1 app you can use Windows.UI.Popups.MessageDialog instead
Async Function ShowMyDialog() As Task(Of Boolean)
Dim result As Boolean = False
Dim dialog As New Windows.UI.Popups.MessageDialog("Would you like to see the simple version?", "MessageDialog Example")
dialog.Commands.Add(New Windows.UI.Popups.UICommand("Ok",
Async Sub(command)
result = True
Dim okDialog As New Windows.UI.Popups.MessageDialog("No caption, one button.")
Await okDialog.ShowAsync()
End Sub))
dialog.Commands.Add(New Windows.UI.Popups.UICommand("Cancel"))
dialog.DefaultCommandIndex = 0
dialog.CancelCommandIndex = 1
Await dialog.ShowAsync()
Return result
End Function
I wrote a vb.net program using Visual Studio 2010 Express to open and manipulate an Excel workbook. I have MS Office 2010 and my program works fine on my computer. When I try to run it on my wife's computer... nothing. I get no error messages... nothing. She has the same version of Office as I do, but she has Windows XP and I have Vista and her computer is has more security protocols than mine, but my other program, which does not import any Office namespaces, runs fine on her computer.
When I look at the task manager on her computer there is nothing under the Applications tab, but under the Processes tab I see an instance of Excel.exe, and if I try to run the program again, still nothing under applications, but yet another instance of Excel.exe under processes.
I have tried to install my program using the Click-Once technology and just the Release folder after a Rebuild... nothing.
I have also tried to compile it under versions 2.0, 3.0, etc.... nothing.
Here is some of the relevant code:
Public Class CleanUpDataForm
Dim m_objExcel As New Excel.Application
Dim m_rngRange, m_rngEnd As Excel.Range
Dim m_blnEntireRow, m_blnCancel As Boolean
Dim m_strRange, m_strSearch, m_strLogFrameCode As String
Const c_strCode As String = "log"
Friend Const c_intScrollBarWidth As Integer = 30
Private Sub CleanUpDataForm_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
m_objExcel = Nothing
Dispose()
End Sub
Private Sub tsbOpen_Click(sender As System.Object, e As System.EventArgs) Handles tsbOpen.Click
ofdGetWorksheet.Title = "Select Worksheet"
ofdGetWorksheet.Filter = "All Excel Files (*.xl*)|*.xl*|(*.xlsx)|*.xlsx|(*.xlsm)|*.xlsm|(*.xlsb)|*.xlsb|(*.xlam)|*.xlam|(*.xltx)|*.xltx|(*.xltm)|*.xltm|(*.xls)|*.xls|(*.xla)|*.xla|(*.xlt)|*.xlt|(*.xlm)|*.xlm|(*.xlw)|*.xlw"
ofdGetWorksheet.FileName = ""
If ofdGetWorksheet.ShowDialog <> System.Windows.Forms.DialogResult.Cancel Then
Me.Text = ofdGetWorksheet.FileName
m_objExcel.Workbooks.Open(Me.Text)
tsbCopySheet.Enabled = True
tsbFindRows.Enabled = True
tsbClose.Enabled = True
m_objExcel.Visible = True
Else
Me.Text = ""
End If
Me.Activate()
End Sub
Any ideas??
I believe that I was having this issue as well, but this line of code (after your m_objExcel.visible statement) was what fixed it (going from memory).
m_objExcel.Windows(1).Visible = True
One thing you may want to look at is the Marshal.BindToMoniker method in the InteropServices library. I found this incredibly useful. If the file is not open, then it opens it. If it is open already, then it will use that instance. Like this...
wb = System.Runtime.InteropServices.Marshal.BindToMoniker(fileName) 'open the file. If the file is already open, then this uses the open file instead of trying to open again
exApp = wb.Parent
wb is my workbook variable, exApp is my Excel variable.
One other thing; to make sure Excel is closed and to remove those pesky processes from Task Manager
Private Sub KillExcel()
For Each RunningProcess In Process.GetProcessesByName("Excel")
RunningProcess.Kill()
Next
End Sub
I'm new to Visual Basic, and I'm having trouble with a program that I'm working on. I'm using the Sterling ActiveX library to create a basic functional program that does an easy task (sending an order) for the Sterling Trader software. I'm just trying to make something basic that works and that I can build off of. Here's my code so far:
Imports SterlingLib
Public Class Form1
Dim WithEvents m_STIEvents As STIEvents
Private Declare Sub GetLocalTime Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME)
Private Structure SYSTEMTIME
Dim wYear As Short
Dim wMonth As Short
Dim wDayOfWeek As Short
Dim wDay As Short
Dim wHour As Short
Dim wMinute As Short
Dim wSecond As Short
Dim wMilliseconds As Short
End Structure
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
m_STIEvents = New STIEvents
End Sub
Private Sub m_STIEvents_OnSTIOrderUpdateMsg(ByVal oSTIOrderUpdateMsg As SterlingLib.STIOrderUpdateMsg) Handles m_STIEvents.OnSTIOrderUpdateMsg
Dim order As STIOrder
order = New STIOrder
Dim storder As structSTIOrder
storder.bstrAccount = "ACCT7"
storder.bstrSide = "B"
storder.bstrSymbol = "CSCO"
order.Quantity = "500"
storder.bstrStrPriceType = SterlingLib.STIPriceTypes.ptSTIMkt
storder.bstrTif = "D"
storder.bstrDestination = "NYSE"
Dim theTime As SYSTEMTIME
GetLocalTime(theTime)
storder.bstrClOrderId = storder.bstrAccount & theTime.wYear & theTime.wMonth & theTime.wDay & theTime.wHour & theTime.wMinute & theTime.wSecond & theTime.wMilliseconds
Dim ret As Integer
ret = order.SubmitOrder
End Sub
Private Function Text1() As Object
Throw New NotImplementedException
End Function
End Class
When I run this program, I get the following error:
"Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.
Retrieving the COM class factory for component with CLSID {5E89F49B-6A12-420F-8570-E510EF1B580A} failed due to the following error: 800700c1."
What does this mean, and how can I correct it? When I debug, it highlights "m_STIEvents = New STIEvents" as the line where things are going wrong, but I can't figure it out.
You can reverse-engineer the error code, 0x800700c1. If not through Google then by design. The 8 makes it an error. The 7 is the "facility code", where the error originated, 7 means Windows. Which makes the last 4 digits a Windows error code. 0x00c1 = error 193. Which you can lookup many ways, one is by looking at the Windows SDK's WinError.h file:
//
// MessageId: ERROR_BAD_EXE_FORMAT
//
// MessageText:
//
// %1 is not a valid Win32 application.
//
#define ERROR_BAD_EXE_FORMAT 193L
The kind of error code that's invariably generated on a 64-bit operating system. Running 64-bit code and trying to load a legacy 32-bit ActiveX component.
Which suggests the easy fix: right-click your EXE project in the Solution Explorer windows. Properties, Compile tab, scroll down, Advanced Compile Options button. Change the Target CPU setting to "x86" to force your VB.NET code to run in 32-bit mode so it can load that ActiveX control. Or if it is already set to x86 then change it to "AnyCPU" to take care of the oddball chance that this is a 64-bit ActiveX control.
Contact the vendor of the component if that didn't work or you have any additional problems.
I don't know if you have solved this problem. The way I solved it was installing vb6 on my computer. I tried all the other ways and none of those works. This API is pretty old. Install vb6 solved my problem. Also if you want the program work, you have to login sterling trader pro. Good luck.
I created a simple windows service on my local PC and added the following code to it
Protected Overrides Sub OnStart(ByVal args() As String)
Const iTIME_INTERVAL As Integer = 60000 ' 60 seconds.
Dim oTimer As System.Threading.Timer
System.IO.File.AppendAllText("C:\AuthorLog.txt", _
"AuthorLogService has been started at " & Now.ToString())
Dim tDelegate As Threading.TimerCallback = AddressOf EventAction
oTimer = New System.Threading.Timer(tDelegate, Me, 0, iTIME_INTERVAL)
End Sub
Protected Overrides Sub OnStop()
End Sub
Public Sub EventAction(ByVal sender As Object)
System.IO.File.AppendAllText("C:\AuthorLog.txt", _
"AuthorLogService fires EventAction at " & Now.ToString())
End Sub
Next I added a Setup project to this solution and added a custom action (By double clicking application folder then clicking add output folder then selecting primary output from the dialog). The solution builds fine but I have 2 problems.
1) Everytime I install the service, it asks me for the username, password and confirm password; I was wondering if there was anyway to get rid of it atleast while running locally. I tried setting the account type to user, local service, local system etc but it keeps popping up.
2) Once I enter the credentials (random ones), I get an error "No mapping between account names and security ids was done".
Kindly help me out
1: You could make your service be selfinstalling as in this codeproject article and then just send in the username/password you want to use to the ServiceProcessInstaller.
2: Try entering the credentials in a different format. If you're currently using ".\user" try writing "computer\user" or vice versa.