I have a WPF application that I would like to configure to use NBug to send error reports via email.
The config tool works correctly, and I receive a test email, but when adding NBug to the application and triggering an uncaught exception, I do not receive an email. The only configuration I have done matches the Getting Started guide (loosely translated to VB.Net).
Private Sub Application_Startup(sender As Object, e As StartupEventArgs) Handles Me.Startup
AddHandler AppDomain.CurrentDomain.UnhandledException, NBug.Handler.UnhandledException
AddHandler Application.Current.DispatcherUnhandledException, NBug.Handler.DispatcherUnhandledException
AddHandler TaskScheduler.UnobservedTaskException, NBug.Handler.UnobservedTaskException
NBug.Settings.UIMode = NBug.Enums.UIMode.Full
NBug.Settings.StoragePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
NBug.Settings.AddDestinationFromConnectionString("Type=Mail;From=bugs#xxx.com;Port=465;SmtpServer=smtp.gmail.com;To=support#xxx.com;UseAttachment=True;UseAuthentication=True;UseSsl=True;Username=bugs#xxx.com;Password=xxx;")
NBug.Settings.ReleaseMode = True
End Sub
The above code has removed username/password from our gmail account that is used for bug reports.
Any ideas what is wrong with the config or how I could debug?
The zip file attachment is being generated, but no email is sent.
Simply use NBug.Settings.ReleaseMode = true; as described in this intro post: http://www.soygul.com/nbug/
Related
I am using WPF control for CefSharp. I need to know when the request I made receives a response with http status code 404.
I've noticed that CefSharp has LoadError event, but that only fires when the domain cannot be resolved altogether (i.e. if I go to www.sdfhjkhajsdf.com). It doesn't work for when the domain exists, but the page your requesting doesn't.
This is a pretty old question. CefSharp has had lots of great updates, so I hope this helps others searching like me. Don't hate me because my snippets are in VB.NET. ;)
This is what I'm doing to log anything that is not 200 response. For my application, I open a new form of the requested page, so I limit my focus to the initial page request by looking at the ReferrerUrl property. Obviously, you could drop that part to be alerted to all requests.
When you initially implement your ChromiumWebBrowser you need to set a RequestHandler to your implementation.
Me.chromeBrowser = New CefSharp.WinForms.ChromiumWebBrowser(uri)
Me.chromeBrowser.RequestHandler = New CefBasicRequestHandler()
Me.Controls.Add(Me.chromeBrowser)
CefSharp released a default implementation that you can use and just override OnResourceResponse.
Imports System.Security.Cryptography.X509Certificates
Imports CefSharp
Public Class CefBasicRequestHandler
Inherits CefSharp.Handler.DefaultRequestHandler
Private Shared ReadOnly Logger As log4net.ILog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
Public Overrides Function OnResourceResponse(browserControl As IWebBrowser, browser As IBrowser, frame As IFrame, request As IRequest, response As IResponse) As Boolean
If String.IsNullOrWhiteSpace(request.ReferrerUrl) Then ' this is the first request of the page
Dim method As String = "OnResourceResponse()."
Dim requestOverview As String = $"[{response.StatusCode}] [{request.Url}]"
Logger.Info($"{method} {requestOverview}")
If response.StatusCode <> 200 Then
Logger.Warn($"{method} {requestOverview}")
End If
End If
Return MyBase.OnResourceResponse(browserControl, browser, frame, request, response)
End Function
End Class
So I have a report server in a local area network that I want to access via a winform application with a Report viewer
my Report viewer control Name is rpt_ReportViewer
and here's the Code to view reports on the reportviewer rpt_ReportViewer
Private Sub rpt_GenerateReportBtn_Click(sender As Object, e As EventArgs) Handles rpt_GenerateReportBtn.Click
With rpt_ReportViewer
.ServerReport.ReportServerUrl = New Uri("http://SERVER/ReportServer")
.ServerReport.ReportPath = "/Search Assets Table/Search Assets Table"
.RefreshReport()
End With
End Sub
whenever I run this code it generates an exception in the report viewer saying "The Request Failed with HTTP Status 401: Unauthorized."
I don't know whats wrong but I used this very same code on a localhost and it worked http://localhost/reportserver
can anyone help me figuring out whats wrong please ? thanks in advance.
There's the solution
Dim Credential As New NetworkCredential("User name", "Password") 'Was missing this Line
With rpt_ReportViewer
.ServerReport.ReportServerCredentials.NetworkCredentials = Credential 'Was missing this line too
.ServerReport.ReportServerUrl = New Uri("http://SERVER/ReportServer")
.ServerReport.ReportPath = rpt_ReportsListBox.SelectedValue
.RefreshReport()
End With
I've been searching the net for a basic sample winforms app that is written in vb.net to upload a file to onedrive. Does anyone know of any?
I'm trying to get a file uploaded with a winforms app in vb.net. I'm as far as getting the auth working... but calling the next method returns a 401...
I did the following:
Shared scope As String = "wl.skydrive_update"
Shared client_id As String = "0000000040144E26"
Shared signInUrl As New Uri([String].Format("https://login.live.com/oauth20_authorize.srf?client_id={0}&redirect_uri=https://login.live.com/oauth20_desktop.srf&response_type=code&scope={1}", client_id, scope))
Private Sub cmdOneDriveAuth_Click(sender As Object, e As EventArgs) Handles cmdOneDriveAuth.Click
Try
Dim auth As New FrmAuthBrowser
auth.WebBrowser1.Navigate(signInUrl)
auth.Show()
Catch ex As Exception
End Try
End Sub
and then in the auth window:
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Try
If WebBrowser1.Url.AbsoluteUri.Contains("code=") Then
Dim AuthCode As String = System.Web.HttpUtility.ParseQueryString(WebBrowser1.Url.Query)("code")
My.Settings.OneDrive_Enabled = True
My.Settings.OneDrive_AuthCode = AuthCode
My.Settings.Save()
Me.Dispose()
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
but when I try and get the root info, I get a 401...
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim client As New WebClient()
Dim result = client.OpenRead(New Uri("https://apis.live.net/v5.0/me/skydrive?access_token=" + My.Settings.OneDrive_AuthCode))
Dim sr As StreamReader = New StreamReader(result)
MsgBox(sr.ReadToEnd())
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Can anyone provide me with some guidance?
Looks like you're using the 'code' flow of OAuth, but you're missing a step. The 'code' you get back isn't the same as the access_token. You need to make another call to the login server first to exchange your code for an access_token.
POST https://login.live.com/oauth20_token.srf
Content-Type: application/x-www-form-urlencoded
client_id={client_id}&redirect_uri={redirect_uri}&client_secret={client_secret}
&code={code}&grant_type=authorization_code
You can find more details here http://onedrive.github.io/auth/msa_oauth.htm#code-flow.
OneDrive just released a new API, so I would encourage you to check it out. http://onedrive.github.io/
There's also a sample Windows/C# app that you can look at for reference on how to sign in and upload files. https://github.com/OneDrive/onedrive-explorer-win
I am attempting to add smart exception handling to a Silverlight 4 RIA application that is primarily consumed out-of-browser.
My goal is to display a meaningful error window if RIA services are not currently accessible (e.g. The server is down for maintenance)
Is there any facility built into RIA/SL for this task?
I use the following to check to see if my user has network access which may get you the answer you are looking for.
Private Sub CheckMode()
If Application.Current.IsRunningOutOfBrowser Then
currentMode.Text = "Operating Mode: Out of Browser"
Else
currentMode.Text = "Operating Mode: In Browser"
End If
currentMode.Foreground = New SolidColorBrush(Colors.White)
End Sub
Private Sub UpdateNetworkIndicator(ByVal sender As Object, ByVal e As System.EventArgs)
If WebContext.Current.User.IsAuthenticated Then
If NetworkInterface.GetIsNetworkAvailable Then
connectionStatus.Text = "Network Status: Connected"
connectionStatus.Foreground = New SolidColorBrush(Colors.Green)
Else
connectionStatus.Text = "Network Status: Disonnected"
connectionStatus.Foreground = New SolidColorBrush(Colors.Red)
End If
End If
End Sub
When working on ASP.NET 1.1 projects I always used the Global.asax to catch all errors. I'm looking for a similar way to catch all exceptions in a Windows Forms user control, which ends up being a hosted IE control. What is the proper way to go about doing something like this?
You need to handle the System.Windows.Forms.Application.ThreadException event for Windows Forms. This article really helped me: http://bytes.com/forum/thread236199.html.
Currently in my winforms app I have handlers for Application.ThreadException, as above, but also AppDomain.CurrentDomain.UnhandledException
Most exceptions arrive via the ThreadException handler, but the AppDomain has also caught a few in my experience
If you're using VB.NET, you can tap into the very convenient ApplicationEvents.vb. This file comes for free with a VB.NET WinForms project and contains a method for handling unhandled exceptions.
To get to this nifty file, it's "Project Properties >> Application >> Application Events"
If you're not using VB.NET, then yeah, it's handling Application.ThreadException.
To Handle Exceptions Globally...
Windows Application
System.Windows.Forms.Application.ThreadException event
Generally Used in Main Method. Refer MSDN Thread Exception
Asp.Net
System.Web.HttpApplication.Error event
Normally Used in Global.asax file. Refer MSDN Global.asax Global Handlers
Console Application
System.AppDomain.UnhandledException event
Generally used in Main Method. Refer MSDN UnhandledException
Code from MSDN: http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2
Sub Main()
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
AddHandler currentDomain.UnhandledException, AddressOf MyHandler
Try
Throw New Exception("1")
Catch e As Exception
Console.WriteLine("Catch clause caught : " + e.Message)
Console.WriteLine()
End Try
Throw New Exception("2")
End Sub
Sub MyHandler(sender As Object, args As UnhandledExceptionEventArgs)
Dim e As Exception = DirectCast(args.ExceptionObject, Exception)
Console.WriteLine("MyHandler caught : " + e.Message)
Console.WriteLine("Runtime terminating: {0}", args.IsTerminating)
End Sub