Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception #50

Open
KushX opened this issue Oct 3, 2019 · 1 comment
Open

Unhandled Exception #50

KushX opened this issue Oct 3, 2019 · 1 comment

Comments

@KushX
Copy link

KushX commented Oct 3, 2019

I've seen #43, and I'm using v.1.2.1 via NuGet.
I have multiple machines which get this issue (shown below).
I'm not sure what's causing it, but I simply CANNOT manage to catch the exception! It's always an unhandled exception.
Any suggestions how to handle the exception?

`System.Xml.XmlException: There are multiple root elements. Line 1, position 2.
at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
at System.Xml.XmlBaseReader.EnterScope()
at System.Xml.XmlUTF8TextReader.ReadStartElement()
at System.Xml.XmlUTF8TextReader.Read()
at System.Xml.XmlBaseReader.ReadEndElement()
at System.Runtime.Serialization.XmlReaderDelegator.ReadEndElement()
at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)

System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type CSharpAnalytics.Sessions.SessionState. There are multiple root elements. Line 1, position 2.
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(XmlDictionaryReader reader)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(Stream stream)
at CSharpAnalytics.Serializers.AppDataContractSerializer.d__01.MoveNext() at End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CSharpAnalytics.WinFormAutoMeasurement.<Load>d__01.MoveNext()
at End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CSharpAnalytics.BaseAutoMeasurement.d__0.MoveNext()
at End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_1(Object state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()`

@KushX
Copy link
Author

KushX commented Oct 18, 2019

Anyone have any suggestions on how to avoid these crashes??!?

Adding the below seems to handle most of the errors now. However, not all.
gAnalytics.DebugWriter = Sub(d) _logger.Error(d) 'Debug.WriteLine(d)

So logging (and therefore avoiding exception errors) works for calls such as this:
gAnalytics.Client.Track(New CSharpAnalytics.Activities.AppViewActivity(Me.Text))

But simply doesn't work for this:
Dim GA As New CSharpAnalytics.Activities.TransactionActivity() For Each s As Product In ramDoc.Products CSharpAnalytics.Activities.TransactionItemExtensions.AddItem(GA, s.ProductID, s.Description, s.UnitPrice, s.Quantity) Next With GA .StoreName = MyCompany.CompanyName & ":" & ramDoc.WarehouseID_From .OrderId = ramDoc.DocumentNo .OrderTotal = ramDoc.DocumentTotal .TaxCost = ramDoc.DocumentVAT .Currency = "KES" End With gAnalytics.Client.Track(GA)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant