Giter Club home page Giter Club logo

nbug's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nbug's Issues

3 mantis tickets are created

Hi,

I set up in the app a destination to create a mantis ticket when an error is thrown. I set the following connection string :

Type=Mantis;Username=administrator;Password=P@ssw0rdj;Url=http://mantis.hostname.fr/api/soap/mantisconnect.php;ProjectId=1;Category=General;Severity=70;Status=10;SendAttachment=False;SuccessIfAttachmentFails=False;AddVersionIfNotExists=False;

But when I check mantis, it has created 3 exact same tickets :
2020-10-06_221407

I don't know what am I missing...

Thanks,
A.

Reports not sent when configured from the code

Hi people,

I'm trying to configure NBug through code, by using these lines:

#if DEBUG
    NBug.Settings.StoragePath = NBug.Enums.StoragePath.CurrentDirectory;
#else
    NBug.Settings.StoragePath = NBug.Enums.StoragePath.IsolatedStorage;
#endif
    NBug.Settings.UIProvider = NBug.Enums.UIProvider.Custom;
    NBug.Settings.CustomUIEvent += Settings_CustomUIEvent;
    NBug.Settings.AddDestinationFromConnectionString("Type=Redmine;ApiKey=...;ProjectId=...;Url=http://...;");
    NBug.Settings.ReleaseMode = true;

All works normally, except the report is never sent and zip file never deleted. If I use NBug.config file with exact the same destination string, all is good. Watch shows that Destination list looks good, other settings/defaults correspond to .config file, I even tried to ditch AddDestinationFromConnectionString and manually create an item), with or without ReleaseMode, always the same.

Am I missing something important here?

Thank you in advance!

Blocking Thread

Sleep Before Send Values are ignored and NBug Blocks application till upload via FTP is complete

<NBug.Properties.Settings>
      <setting name="UIMode" serializeAs="String">
        <value>Auto</value>
      </setting>
      <setting name="UIProvider" serializeAs="String">
        <value>Auto</value>
      </setting>
      <setting name="SleepBeforeSend" serializeAs="String">
        <value>25</value>
      </setting>
      <setting name="MaxQueuedReports" serializeAs="String">
        <value>5</value>
      </setting>
      <setting name="StopReportingAfter" serializeAs="String">
        <value>30</value>
      </setting>
      <setting name="MiniDumpType" serializeAs="String">
        <value>Tiny</value>
      </setting>
      <setting name="WriteLogToDisk" serializeAs="String">
        <value>true</value>
      </setting>
      <setting name="ExitApplicationImmediately" serializeAs="String">
        <value>true</value>
      </setting>
      <setting name="HandleProcessCorruptedStateExceptions" serializeAs="String">
        <value>false</value>
      </setting>
      <setting name="ReleaseMode" serializeAs="String">
        <value>false</value>
      </setting>
      <setting name="DeferredReporting" serializeAs="String">
        <value>true</value>
      </setting>
      <setting name="StoragePath" serializeAs="String">
        <value>CurrentDirectory</value>
      </setting>
    </NBug.Properties.Settings>

Bug in ConnectionStringParser.

I've found a pretty funny bug inside the ConnectionStringParser and I'm not sure if there is a "elegant way" for solve it.
If in the connection string you have an HTML entity you got a NBugConfigurationException.

For example:
NBug.Settings.AddDestinationFromConnectionString("Type=Mail;CustomBody=My fancy body.;CustomSubject=Crash Report;" +
"From=[email protected];FromName=Bugreport - Me &amp; my friends;" +
"Password=mysecredpassword;Port=587;Priority=Low;SmtpServer=mailserver.example.com;To=[email protected];" + "UseAttachment=True;UseAuthentication=True;UseSsl=False;Username=mymailusername;");

is a valid connection string, but it doesn't work because of the &amp; in the FromName field.
Maybe in the .conf file it work, but not if you put in the code directly and I'm not sure it's safe put the entities in the "normal" form (like & for the &amp;).

Thanks a lot in advance!

NBug crashes when SoapFault error or SqlException is thrown

Method WriteXml in SerializableDictionary fails to serialize some exceptions (IE. GUID, SqlError, FaultCode, etc...)

Since we're not sure if XMLWriter will in fact be able to serialize dictionary value and it's impossible to enumerate all various exception types and their properties I suppose there is no nice solution to this.

I've modified original method to check if Type is serializable or not, and event if it is, I've wrapped it with try/catch since I noticed SqlErrorCollection is serializable but XMLWriter still fails. I didn't want to make pull request in case someone has better idea...

    public void WriteXml(XmlWriter writer)
    {
        foreach (var key in this.Keys)
        {
            writer.WriteStartElement(key.ToString());
            // Check to see if we can actually serialize element
            if (this[key].GetType().IsSerializable)
            {
                // if it's Serializable doesn't mean serialization will succeed (IE. GUID and SQLError types)
                try
                {
                    writer.WriteValue(this[key]);
                }
                catch (Exception)
                {
                    // we're not Throwing anything here, otherwise evil thing will happen
                    writer.WriteValue(this[key].ToString());
                }
            }
            else
            {
                // If Type has custom implementation of ToString() we'll get something useful here
                // Otherwise we'll get Type string. (Still better than crashing).
                writer.WriteValue(this[key].ToString());
            }
            writer.WriteEndElement();
        }
    }

Type conversion/Uppercase bug

The string builder helper outputs 'yes' while the parser looks for 'True/False'.
And property assignments are case sensitive.

UseSsl is in an incorrect case in the helper.

Receive all errors

Nbug works great for bugs that crash the program.. but I want to get the same notifications for handled errors, meaning such errors that doesn't crash the program but its still a error, since its in a try catch.

Is that possible to do with the current library, or I need to modify it?

Catch SmtpException when the computer doesn't have an access to the network

NBug error dialog is displayed at the start of an application whether an old Exception archive zip exists and the computer doesn't have an access to the network. The SmtpException is thrown by Send method of SmtpClient class with the message The remote name could not be resolved: ''.

I think that NBug doesn't have to display the error dialog whether the network or the host is not reachable. It have to retry to send it the next start.

Support for custom exception serialization

Currently there is no way I could get any non serializable extended data which is kind of BIG issue for us. NBug tries to serialize all it possibly can, and fallbacks to ToString method if everything else fails. That's OK, but there are situations where end user wants to check the type of original exception, and do custom serialization depending on exception type/error code/message...

For example, SQLException has non serializable Errors property which is of SqlErrorCollection type. 90% it's the ExtendedInformation that has all the data we need to get usefull information. We could easily create method inside NBUG to check for SQLExceptions and do custom serialization for non serializable SQLErrorCollection but this is not maintainable and covers only one specific type. Other (custom) exception types should not be second class citizens.

IMHO only solutions is to create SerializationEvent so user can subscribe and handle serialization manually. Event would be fired after NBug has done all it can to serialize the exception, so user only has to worry about specific exceptions. SerializationEventArgs would be original exception thrown and a reference to SerializableException made.

I guess I could try to implement it but just didn't want to hack the NBug that deep.

Issue: Invalid ZIP file crashes NBug

When exception is thrown, after UI dialog is displayed NBug creates ZIP file in specified location. If internal exception occurs in NBug, it will leave invalid ZIP file on disk.
On every subsequent application start NBug will try to load invalid ZIP file, generate IO Exception, crash and warn user about it's internal exception. Note that empty ZIP file is handled just fine.

Proposed solution:

Create ZIP file at temporary location (or memory) and move it to the right location once when serialization is done or ensure that ZIP archive is always valid even if NBug crashes.

Unable to send Mantis bug report via HTTPS.

When trying to send a Mantis bug report over HTTPS, the following exception occurs:

Exception: System.ArgumentException
Message: The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via
Target Site Void ValidateScheme(System.Uri) @ System.ServiceModel.Channels.TransportChannelFactory`1[TChannel]
Source: System.ServiceModel
ParamName: via
HResult: -2147024809
Stack Trace:

at System.ServiceModel.Channels.TransportChannelFactory`1.ValidateScheme(Uri via)
   at System.ServiceModel.Channels.HttpChannelFactory`1.ValidateCreateChannelParameters(EndpointAddress remoteAddress, Uri via)
   at System.ServiceModel.Channels.HttpChannelFactory`1.OnCreateChannelCore(EndpointAddress remoteAddress, Uri via)
   at System.ServiceModel.Channels.HttpChannelFactory`1.OnCreateChannel(EndpointAddress remoteAddress, Uri via)
   at System.ServiceModel.Channels.ChannelFactoryBase`1.InternalCreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.ChannelFactoryBase`1.CreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.ServiceChannelFactory.ServiceChannelFactoryOverRequest.CreateInnerChannelBinder(EndpointAddress to, Uri via)
   at System.ServiceModel.Channels.ServiceChannelFactory.CreateServiceChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.Channels.ServiceChannelFactory.CreateChannel(Type channelType, EndpointAddress address, Uri via)
   at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.ChannelFactory`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannelInternal()
   at System.ServiceModel.ClientBase`1.get_Channel()
   at NBug.Core.Submission.Tracker.Mantis.MantisConnectService.mc_login(String username, String password)
   at NBug.Core.Submission.Tracker.Mantis.Mantis.Send(String fileName, Stream file, Report report, SerializableException exception)
   at NBug.Core.Submission.Dispatcher.EnumerateDestinations(Stream reportFile, ExceptionData exceptionData)

As MantisHub (sensibly) redirects HTTP to HTTPS, trying to submit a bug report sends back a redirect, which is of course an empty response. This causes the following exception to occur:

Exception: System.ServiceModel.ProtocolException
Message: The content type text/html of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 0 bytes of the response were: ''.
Target Site Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage) @ System.Runtime.Remoting.Proxies.RealProxy
Source: mscorlib
ParamName: via
HResult: -2146233087
Stack Trace:

Server stack trace: 
   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at NBug.Core.Submission.Tracker.Mantis.IMantisConnectService.mc_login(String username, String password)
   at NBug.Core.Submission.Tracker.Mantis.MantisConnectService.mc_login(String username, String password)
   at NBug.Core.Submission.Tracker.Mantis.Mantis.Send(String fileName, Stream file, Report report, SerializableException exception)
   at NBug.Core.Submission.Dispatcher.EnumerateDestinations(Stream reportFile, ExceptionData exceptionData)

Is the NuGet package supported? Is master assumed to be stable when building?

The NuGet package looks like it stopped being updated in 2013, while this project appears to have been developed well into 2017.

The README suggests to build the DLL myself, but there's no tags or releases - is it assumed that the master branch will always produce a stable build?

Is there a reason the NuGet package is so old?

Re-enable Release build configuration for WPF project

With some work, we can re-enable it with something like Condition="$(OS) == 'WINDOWS_NT'" without breaking Travis build. If that's not possible, we can create a new build target called Travis and selective add needed projects.

Protocols.cs license question

Hi,

The file Submission/Protocols.cs still contains the LGPL license header. Is this a mistake or oversight?
If not, how does it impact with the rest of the files being MIT Licensed?
Thanks

Wrong xml .config output

Hey guys,

first of all: that's a great project, thank you!
I used your configurator to setup my NBug.config file. I used redmine as an issue tracker and everything works like a charm. But after using that very same config lines in my own app, there were no reports sent anymore.

After debugging your project I found out that the auto-generated .config file adds a connection like this:

<add name="NBug.Properties.Settings.Connection1" connectionString="Type=Redmine;ApiKey=xxxxxxxxxxxxxxxxxxxxxxxxx;ProjectId=crashltsw;Url=http://12.345.67.890/redmine/;" />

The problem was that after reading the .config file everything was parsed correctly except the connection. I figured that there was an error with the .config file because connections are named incorrectly.

So instead of naming it "Connection1" it should say "Destination1".

The correct line in the .config file would be like this:
<add name="NBug.Properties.Settings.Destination1" connectionString="Type=Redmine;ApiKey=xxxxxxxxxxxxxxxxxxxxxxxxx;ProjectId=crashltsw;Url=http://12.345.67.890/redmine/;" />

Everything worked as expected after changing the connection's name.

Best,
m

MySQL exception leads to invalid Exception.xml

V1.2.2 (nuget)

A simple duplicate id error from mysql leads to an invalid Exception.xml.

Then NBug subsequently crashes until the files is moved/deleted/renamed. This is a real showstopper.

Here is the faulty Exception.xml (part of it)
<?xml version="1.0"?>
<SerializableException xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Data>
<Server Error Code>1062</Server Error Code>
</Data>
<ExtendedInformation>
<Number>1062</Number>
<ErrorCode>-2147467259</ErrorCode>
<HResult>-2147467259</HResult>
</ExtendedInformation>
<Message>Duplicate entry '15' for key 'PRIMARY'</Message>
<Source>MySql.Data</Source>
<StackTrace> bei MySql.Data.MySqlClient.MySqlStream.ReadPacket()
bei MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
bei MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
bei MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
bei MySql.Data.MySqlClient.MySqlDataReader.NextResult()
bei MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)

Server Error Code is obviously wrong. If you could point me in the right direction please, because i really need a fix for that.

Error in Report.ToString()

Theres an error in Report.ToString() and SerializableException.ToString().
Here is the correction.

using (var stream = new MemoryStream())
{
stream.SetLength(0);
serializer.Serialize(stream, this);
stream.Position = 0;
var doc = XDocument.Load(stream);
return doc.Root.ToString();
}

NBug submits bug immediately after application starts

I've tested current master branch and seems to me property Property Settings.SleepBeforeSend is ignored and Bugs are submitted immediately.

Reproduce steps:

  • pull current master branch
  • create new configuration
  • add FTP destination with invalid url (ie. ftp://blah.com)
  • save configuration and start example app

NBug exception is thrown immediately on app start.
Expected behavior is that exception is thrown after 10 seconds (with default settings)

customize

Hi,

I would like to customize the exception handling.

  1. Create my own exception form
  2. Create my own Mail protocol that sends just the exception + stack trace as plain text.
  3. Disable the zip, I'm using log4Net

how can I do this?

Windows Forms

Can I use NBug in Windows Forms apps, not only WPF ?

changes

have made some huge changes to the way your library functions. specifically:

  1. I am using DotNetZip as the compression library instead of your hand crafted compression. http://dotnetzip.condeplex.com
  2. created a Serializable version of System.Version for use in SerializableException (also heavily rewritten)
  3. heavily modified Settings.cs so that settings are stored\retrieved properly (the way I think it should be done) in app.config Created custom classes inheriting from ConfigurationSection, ConfigurationElementSection, and ConfigurationElement to load from app.config. instead of loading as xml and parsing I preferred this method as access. its a little clunky, could be improved?!
  4. rewrote Core.Submission.Web.Mail.cs to send emails via MAPI. basically uses the default email provider setup on users machine to send report. was a hassle with smtp server setup and properly knowing WHO it came from. I need to know who it came from if I have my app installed on multiple users machines. who broke it sort of thing.

Submit of report with CustomInfo fails

Hi!

When creating a bug report with CustomInfo object set, NBug throws an exception when trying to submit this report. This problem was mentioned earlier here on StackOverflow.

In Report.cs the report class gets serialized in the ToString Methodwith this code:
var serializer = this.CustomInfo != null
? new XmlSerializer(typeof(Report), new[] { this.CustomInfo.GetType() })
: new XmlSerializer(typeof(Report));
so if setting CustomInfo != null the XmlSerializer constructor with the "extraTypes" parameter gets called. See MSDN.

After restarting the application, NBug tries to submit the bug report, this leads to Dispatcher.cs method GetDataFromZip(Stream stream) the deserialization of the report file happens always with the following call: var deserializer = new XmlSerializer(typeof(Report));

Unfortunately this leads to a wrongly deserialized Xml so the CustomInfo member of the Report class gets deserialized to a XmlNode[] which in turn cannot be correctly serialized later when submitting the bugreport.

Kind regards,
Andy

nbug.handler threw an exception

Some of app's users get error:
the type initializer for nbug.hander threw an exception:
System.TypeInitializationException
at nbug.handler.get_UnhandledException

I use WPF application and initialize configuration programmatically:

        AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException;
        Current.DispatcherUnhandledException += NBug.Handler.DispatcherUnhandledException;

        NBug.Settings.StoragePath = NBug.Enums.StoragePath.CurrentDirectory;
        NBug.Settings.UIMode = NBug.Enums.UIMode.Full;
        NBug.Settings.UIProvider = NBug.Enums.UIProvider.WPF;
        NBug.Settings.WriteLogToDisk = true;
        NBug.Settings.ReleaseMode = false;
        NBug.Settings.MiniDumpType = NBug.Enums.MiniDumpType.Full;

Reading the dump in visual studio after beign created

Hello,
I was looking exacly for a project as your in order to detect and report unhandled exception , btw I've tried with a simple project and when I read the dump created I got some issues on the stack..

Consider a really simple exception as

private Task OnFireCommandExecute() { throw new Exception(); }

Now it's currecly catched and the report tells

-

-

-2146233088

Exception of type 'System.Exception' was thrown.

NBugCatelIntegration

at NBugCatelIntegration.ViewModels.MainWindowViewModel.OnFireCommandExecute() in C:\Users\user\Source\Repos\NBugCatelIntegration\NBugCatelIntegration\ViewModels\MainWindowViewModel.cs:line 18 at Catel.MVVM.TaskCommand3.<>c__DisplayClass5_0.<.ctor>b__0(TExecuteParameter executeParameter, CancellationToken cancellationToken, IProgress1 progress) in C:\CI_WS\Ws\97969\Source\Catel\src\Catel.MVVM\Catel.MVVM.Shared\MVVM\Commands\TaskCommand.cs:line 52 at Catel.MVVM.TaskCommand`3.d__30.MoveNext() in C:\CI_WS\Ws\97969\Source\Catel\src\Catel.MVVM\Catel.MVVM.Shared\MVVM\Commands\TaskCommand.cs:line 234 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_0(Object state) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

System.Threading.Tasks.Task OnFireCommandExecute() @ NBugCatelIntegration.ViewModels.MainWindowViewModel

System.Exception

When I open the minidump created (also the full one), I got the following stack

main

Wasn't is suppose to be on the command method?
Thank in advance

Allow integration of new protocols using interfaces

I have recently submitted a pull request that allows you to use Azure Blob Storage as a destination for crash reports. The downside to this is that it takes a dependency on WindowsAzure.Storage, which is very unnecessary for anyone who won't use it.

I propose (and will most likely be implementing) that we restructure so that the only thing one has to do to support a new protocol is to implement a specific interface, e.g. IProtocol. We can have a base class (say ProtocolBase) that provides many of today's niceties, such as parsing existing connection strings.

At the same time, I would convert all the Destination1, Destination2, etc. into a list that can be replaced during configuration:

NBug.Settings.Destinations.Clear();
NBug.Settings.Destinations.Add(
    new AzureBlobStorageProtocol(accountName, accountKey, signature));
NBug.Settings.Destinations.Add(
    new FtpProtocol("Type=FTP;Url=ftp://example.com/path/;UseSSL=false;Username=;Password=;"));

Would this syntax make sense for most people?

To avoid breaking things, we can still keep Destination1 through Destination5 available by mapping them to Destinations, if that is required.

Crash when exception report is empty

I received the following crash reports from a customer (who sent it to me via e-mail). One zip file was empty, the other one contained this error:

<?xml version="1.0"?>
<SerializableException xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ExtendedInformation>
    <HResult>-2146233088</HResult>
  </ExtendedInformation>
  <InnerException>
    <ExtendedInformation>
      <HResult>-2146233079</HResult>
    </ExtendedInformation>
    <InnerException>
      <ExtendedInformation>
        <HResult>-2147467262</HResult>
      </ExtendedInformation>
      <Message>Xml type 'List of xdt:untypedAtomic' does not support a conversion from Clr type 'WebExceptionStatus' to Clr type 'String'.</Message>
      <Source>System.Xml</Source>
      <StackTrace>   at System.Xml.Schema.XmlListConverter.ChangeListType(Object value, Type destinationType, IXmlNamespaceResolver nsResolver)
   at System.Xml.Schema.XmlUntypedConverter.ToString(Object value, IXmlNamespaceResolver nsResolver)
   at System.Xml.XmlWriter.WriteValue(Object value)
   at NBug.Core.Util.Serialization.SerializableDictionary`2.WriteXml(XmlWriter writer)
   at System.Xml.Serialization.XmlSerializationWriter.WriteSerializable(IXmlSerializable serializable, String name, String ns, Boolean isNullable, Boolean wrapped)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSerializableException.Write2_SerializableException(String n, String ns, SerializableException o, Boolean isNullable, Boolean needType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSerializableException.Write3_SerializableException(Object o)</StackTrace>
      <TargetSite>System.Object ChangeListType(System.Object, System.Type, System.Xml.IXmlNamespaceResolver) @ System.Xml.Schema.XmlListConverter</TargetSite>
      <Type>System.InvalidCastException</Type>
    </InnerException>
    <Message>There was an error generating the XML document.</Message>
    <Source>System.Xml</Source>
    <StackTrace>   at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
   at System.Xml.Serialization.XmlSerializer.Serialize(Stream stream, Object o, XmlSerializerNamespaces namespaces)
   at NBug.Core.Reporting.BugReport.CreateReportZip(SerializableException serializableException, Report report)
   at NBug.Core.Reporting.BugReport.Report(Exception exception, ExceptionThread exceptionThread)</StackTrace>
    <TargetSite>Void Serialize(System.Xml.XmlWriter, System.Object, System.Xml.Serialization.XmlSerializerNamespaces, System.String, System.String) @ System.Xml.Serialization.XmlSerializer</TargetSite>
    <Type>System.InvalidOperationException</Type>
  </InnerException>
  <Message>An exception occurred during bug report generation process. See the inner exception for details.</Message>
  <Source>NBug</Source>
  <StackTrace>   at NBug.Core.Util.Logging.Logger.Error(String message, Exception exception)
   at NBug.Core.Reporting.BugReport.Report(Exception exception, ExceptionThread exceptionThread)
   at NBug.Handler.ThreadExceptionHandler(Object sender, ThreadExceptionEventArgs e)
   at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t)
   at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
   at System.Windows.Forms.Control.WndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)</StackTrace>
  <TargetSite>Void Error(System.String, System.Exception) @ NBug.Core.Util.Logging.Logger</TargetSite>
  <Type>NBug.Core.Util.Exceptions.NBugRuntimeException</Type>
</SerializableException>

I have a sneaking suspicion that the initial crash report tried to serialize something that was unserializable, but I haven't been able to confirm that. NBug should in any case probably handle this error better, so it doesn't bring down the whole app.

Process.Start(url) does not always work

On some systems Process.Start(url) will not open the default browser but will throw instead a "Application not found" exception (http://stackoverflow.com/questions/7693429/process-start-to-open-an-url-getting-an-exception)

You should use the following code (OpenInBrowser(url)) to ensure the correct behaviour or at least a fallback.

public class Utils
{
    private static string GetDefaultBrowserCommand()
    {
        try
        {
            // try location of default browser path in Vista
            using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice", false))
            {
                if (key != null)
                {
                    string progid = key.GetValue("progid").ToString();
                    using (RegistryKey classKey = Registry.LocalMachine.OpenSubKey(@"Software\Classes\" + progid + @"\shell\open\command", false))
                    {
                        if (classKey != null)
                        {
                            string command = classKey.GetValue(null).ToString();
                            return command;
                        }
                    }
                }
            }

            //fallback
            using (RegistryKey key2 = Registry.ClassesRoot.OpenSubKey(@"HTTP\shell\open\command", false))
            {
                return key2.GetValue(null).ToString().ToLower().Replace("\"", "");
            }
        }
        catch
        {
            return string.Empty;
        }
    }

    private static void Run(string command){
        var textStream = new System.IO.StringReader(command);
        using (var parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(textStream))
        {
            parser.Delimiters = new string[] { " " };
            parser.HasFieldsEnclosedInQuotes = true; // <--- !!!
            string[] fields;
            while ((fields = parser.ReadFields()) != null)
            {
                if(fields.Length > 0){
                    string path = fields[0];
                    String args = command.Replace(path, "").Replace("\"\" ", "");
                    Process.Start(path, args);
                }
            }
        }
    }

    public static void OpenInBrowser(string url)
    {
        try
        {
            Process.Start(url);
        }
        catch (Win32Exception e)
        {
            try
            {
                string command = GetDefaultBrowserCommand();

                if (command.IndexOf("%1") >= 0)
                {
                    command = command.Replace("%1", url);
                }
                else {
                    command = command + " " + url;
                }

                Run(command);
            }
            catch (Win32Exception err)
            {
                Process.Start("iexplore", url);
            }
        }
    }
}

Changing the connection strings?

I had a discussion with a colleague this morning regarding the connection string format. The goal was the possibility to add certain templated fields to each destination. Say that you want to change the e-mail subject field to make it easier to sort the e-mail, or perhaps you want files stored via ftp to be stored hierarchically in folders: {application}/{version}/{exception}/{timestamp}.zip

We think a lot can be achieved by moving away from connection strings and replacing them with full XML elements, something like this:

<nbug>
    <connection>
        <type>ftp</type>
        <uri>ftp://www.example.com/asdf</uri>
        <username></username>
        <password></password>
        <filenameFormat>Exception_{timestamp}.zip</filenameFormat>
    </connection>
    <connection>
        <type>email</type>
        <server>smtp.example.com</server>
        <port>25</port>
        <username></username>
        <password></password>
        <subject>{version} - {exception} - {method}</subject>
        <template>Hi, an exception was logged: {exception}
            {stacktrace}

            Best regards,
            {applicationName} {version}
        </template>
        <filenameFormat>Exception_{timestamp}.zip</filenameFormat>
    </connection>
    <connection>
        <type>azureblobstorage</type>
        <sharedAccessSignature>1234567890abcdef</sharedAccessSignature>
        <accountName>example</accountName>
        <filenameFormat>{applicationName}/{version}/{exception} {method}/{timestamp}.zip</filenameFormat>
    </connection>
</nbug>

To implement this in the best possible way, I assume we'll change the protocol interface to something like this:

public interface IProtocol<T>
    where T: IProtocolSettings
{
    bool Send(T settings, Stream file);
}

Is this a good idea?

IOException problem in NBug.Core.Util.Storage.Storer.GetFirstReportFile()

if any of generated report file("Exception_*.zip") is being used by other process, following line

AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException;

would raise exception as it reads in NBug.log(Note: the first Korean statement in Log reads 'c:\SmartADC\crash\Mirero.Server.SmartADC.AutoRuleValidate\Exception_130922186655821941.zip' file cannot be accessed because it is being used by other process' or something)

NBugError: Cannot access the report file from the given custom path (it is probably locked, see the inner exception): c:\SmartADC\crash\Mirero.Server.SmartADC.AutoRuleValidate\Exception_130922186655821941.zip
Exception: System.IO.IOException: 'c:\SmartADC\crash\Mirero.Server.SmartADC.AutoRuleValidate\Exception_130922186655821941.zip' 파일은 다른 프로세스에서 사용 중이므로 프로세스에서 액세스할 수 없습니다.
   위치: System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   위치: System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   위치: System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   위치: System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   위치: NBug.Core.Util.Storage.Storer.GetFirstReportFile() 파일 C:\Documents and Settings\Teoman Soygul\My Documents\ASFT\Dev\NBug\Source\NBug\Core\Util\Storage\Storer.cs:줄 287
NBugError: An exception occurred while dispatching bug report. Check the inner exception for details.
Exception: System.InvalidOperationException: 응용 프로그램이 UserInteractive 모드에서 실행되지 않을 때에는 모달 대화 상자나 폼을 표시할 수 없습니다. 서비스 응용 프로그램에서 알림을 표시하려면 ServiceNotification 또는 DefaultDesktopOnly 스타일을 지정하십시오.
   위치: System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   위치: NBug.Core.Util.Logging.Logger.Error(String message, Exception exception) 파일 C:\Documents and Settings\Teoman Soygul\My Documents\ASFT\Dev\NBug\Source\NBug\Core\Util\Logging\Logger.cs:줄 88
   위치: NBug.Core.Util.Storage.Storer.GetFirstReportFile() 파일 C:\Documents and Settings\Teoman Soygul\My Documents\ASFT\Dev\NBug\Source\NBug\Core\Util\Storage\Storer.cs:줄 294
   위치: NBug.Core.Submission.Dispatcher.Dispatch() 파일 C:\Documents and Settings\Teoman Soygul\My Documents\ASFT\Dev\NBug\Source\NBug\Core\Submission\Dispatcher.cs:줄 70
   위치: NBug.Core.Submission.Dispatcher..ctor(Boolean isAsynchronous) 파일 C:\Documents and Settings\Teoman Soygul\My Documents\ASFT\Dev\NBug\Source\NBug\Core\Submission\Dispatcher.cs:줄 41

BTW, I found there is no other process who opened that file because I was able to that file without any problem. I even tried to find the process accessing it by Sysinternal 'handle.exe' utility but failed.

Is there any hint or solution for this?

FYI, my NBug configuration function follows.(my application is console program that is executed by windows service)

// in Main() function

                // https://github.com/soygul/NBug/issues/59 의 설명에 의거, 일단 WriteLogToDisk 옵션을 끔
                // 이렇게 하면 NBug.log는 생성되지 않음.
                NBug.Settings.WriteLogToDisk = false; 
                NBug.Settings.UIMode = UIMode.None;
                NBug.Settings.StoragePath = NBug.Enums.StoragePath.Custom;
                NBug.Settings.StoragePath = (string)SystemPaths.CrashDirectory;
                NBug.Settings.MaxQueuedReports = int.MaxValue;

                AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException;
                TaskScheduler.UnobservedTaskException += NBug.Handler.UnobservedTaskException;

                //Application.ThreadException += NBug.Handler.ThreadException;

Error generating XML document for OleDbError

Trying to make sure my config was setup correctly (ReleaseMode = false) and had some code that threw an exception from the OleDb provider.

Seems that NBug choked trying to save the attachments (I did get an empty zip file however)

NBugTrace: Starting to handle a System.Windows.Forms.Application.ThreadException.
NBugTrace: Starting to generate a bug report for the exception.
NBugTrace: Creating report file to Windows temp path: {%temp%}{%appname%}\Exception_{%timestamp%}.zip
NBugError: An exception occurred during bug report generation process. See the inner exception for details.
Exception: System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidCastException: Xml type 'xdt:untypedAtomic' does not support a conversion from Clr type 'OleDbError' to Clr type 'String'.
at System.Xml.Schema.XmlUntypedConverter.ChangeListType(Object value, Type destinationType, IXmlNamespaceResolver nsResolver)
at System.Xml.Schema.XmlUntypedConverter.ChangeTypeWildcardDestination(Object value, Type destinationType, IXmlNamespaceResolver nsResolver)
at System.Xml.Schema.XmlUntypedConverter.ToString(Object value, IXmlNamespaceResolver nsResolver)
at System.Xml.Schema.XmlListConverter.ListAsString(IEnumerable list, IXmlNamespaceResolver nsResolver)
at System.Xml.Schema.XmlListConverter.ChangeListType(Object value, Type destinationType, IXmlNamespaceResolver nsResolver)
at System.Xml.Schema.XmlUntypedConverter.ChangeListType(Object value, Type destinationType, IXmlNamespaceResolver nsResolver)
at System.Xml.Schema.XmlUntypedConverter.ChangeTypeWildcardDestination(Object value, Type destinationType, IXmlNamespaceResolver nsResolver)
at System.Xml.Schema.XmlUntypedConverter.ToString(Object value, IXmlNamespaceResolver nsResolver)
at System.Xml.XmlWriter.WriteValue(Object value)
at NBug.Core.Util.Serialization.SerializableDictionary`2.WriteXml(XmlWriter writer)
at System.Xml.Serialization.XmlSerializationWriter.WriteSerializable(IXmlSerializable serializable, String name, String ns, Boolean isNullable, Boolean wrapped)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSerializableException.Write2_SerializableException(String n, String ns, SerializableException o, Boolean isNullable, Boolean needType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterSerializableException.Write3_SerializableException(Object o)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(Stream stream, Object o, XmlSerializerNamespaces namespaces)
at NBug.Core.Reporting.BugReport.CreateReportZip(SerializableException serializableException, Report report)
at NBug.Core.Reporting.BugReport.Report(Exception exception, ExceptionThread exceptionThread)

NBug Fails to write minidump file when MiniDump Type = Normal

NBug Crashes when trying to write minidump file when MiniDump Type = Normal.

Info:

OS: Windows 8.1 x64
NBug version: current main snapshot

Steps to reproduce:

  • Create default configuration with NBug.Configurator
  • Set option MiniDump Type to Normal
  • Save and run NBug.Examples.WinForms.exe
  • Click Generate Exception

Error details:

NBug.Core.Util.Exceptions.NBugRuntimeException

Cannot write the minidump. MiniDumpWriteDump (dbghelp.dll) function returned error code: -2147024597

NBug.log hardcoded to write to assembly location

If the application is installed to, and running from Program Files then the application must have admin rights to be able to write back to the same location. If it doesn't then NBug will cause an application crash.

To replicate:
Create a test app with NBug logging on
Copy the application to a protected location, such as program files
Run the application as a normal user (not admin)
It should crash

Possible resolution:
Add a setting to the config to define log path, or use the same path where reports are stored.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.