login about faq

Hi,

I am experiencing an unhandled exception when attempting to load an email from an XML file, but only when the file in question does not contain a complete XML email, for example an empty or corrupt file.

I have the following:

Try
    Dim email as New Email
    If email.LoadXml(sgFile) Then
        'Email successfully loaded, do stuff
    Else
        'Write failure to log file...
    End If

Catch ex As Exception
    'Write error to log file...
End Try

My error handler does not trap the exception and the program terminates unexpectedly. In the system Event Log I see the following 2 events recorded:

  1. Application Error

    Faulting application name: MyProgram.exe, version: 1.1.10.0, time stamp: 0x59ad1431

    Faulting module name: ChilkatDotNet46.dll, version: 9.5.0.65, time stamp: 0x58654057

    Exception code: 0xc0000005

    Fault offset: 0x00000000003adeaa

    Faulting process id: 0x1f44

    Faulting application start time: 0x01d3255b21bb005e

    Faulting application path: C:Program Files (x86)MyMyProgram.exe

    Faulting module path: C:Program Files (x86)MyChilkatDotNet46.dll

    Report Id: 73e25f00-914e-11e7-80eb-00163e57b274

    Faulting package full name:

    Faulting package-relative application ID:

  2. .Net Runtime

    Application: MyProgram.exe

    Framework Version: v4.0.30319

    Description: The process was terminated due to an unhandled exception.

    Exception Info: System.AccessViolationException

    at <module>.ClsEmail.LoadXml(ClsEmail, XString)

    at Chilkat.Email.LoadXml(System.String)

    at MyProgram.MyProgram.MailChecker_ProcessFromXML(Boolean, Boolean ByRef)

    at MyProgram.MyProgram.ImportTimer_Callback(System.Object, System.Timers.ElapsedEventArgs)

    at System.Timers.Timer.MyTimerCallback(System.Object)

    at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)

    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)

    at System.Threading.TimerQueueTimer.CallCallback()

    at System.Threading.TimerQueueTimer.Fire()

    at System.Threading.TimerQueue.FireNextTimers()

Is there any way I can prevent this from happening?

asked Sep 04 at 22:29

webified's gravatar image

webified
32


link

answered Sep 06 at 08:52

chilkat's gravatar image

chilkat ♦♦
12.8k317366476

Awesome. Thanks for being some prompt with a fix for this. I can confirm it has fixed my issue. As a developer it's nice to be on the other side of great support for a change. Keep up the great work.

(Sep 06 at 22:45) webified

Thanks... I'm very sorry for my mistake -- I was thinking you were talking about Xml.LoadXml (not Email.LoadXml). I can't believe I missed what's so clearly stated in both the title and the post. Sorry about that.. I'll re-test.

link

answered Sep 05 at 22:00

chilkat's gravatar image

chilkat ♦♦
12.8k317366476

Thanks! I found and fixed the problem. I'll create a new build for you..

link

answered Sep 06 at 00:12

chilkat's gravatar image

chilkat ♦♦
12.8k317366476

Thanks, I'd need to reproduce the problem to find the cause. If you can, send the input file to support@chilkatsoft.com (in a zipped attachment).

link

answered Sep 05 at 07:39

chilkat's gravatar image

chilkat ♦♦
12.8k317366476

9 don't have access to the files right now, but the last one to cause the error was an empty 0 byte file.

link

answered Sep 05 at 08:09

webified's gravatar image

webified
32

I wasn't able to reproduce the problem. I created an empty file and then called LoadXml(emptyFilePath) and LoadXmlFile(emptyFilePath), and both did not crash, and both returned false to indicate failure.

By the way... you would pass a file path to LoadXmlFile, and pass actual XML text to LoadXml (you don't pass a file path to LoadXml).

I tested with v9.5.0.69, which was recently released, but I don't recall fixing anything related to what you described..

link

answered Sep 05 at 08:43

chilkat's gravatar image

chilkat ♦♦
12.8k317366476

Thanks. I'll double check my calls when I'm back at work tomorrow and post an update her

link

answered Sep 05 at 08:48

webified's gravatar image

webified
32

Hi Chilkat,

I have checked my code, and can confirm I am calling Email.LoadXml(), passing it the path the of XML file. You said in comment above that LoadXml is expecting a string containing XML, but according to the API Reference docs here, https://www.chilkatsoft.com/refdoc/vbnetEmailRef.html, I think I am calling it right:

Function LoadXml(ByVal xmlPath As String) As Boolean

Loads an email with the contents of an XML email file.

Returns True for success, False for failure.

Function LoadXmlString(ByVal xmlStr As String) As Boolean

Loads an email from an XML string (previously obtained by calling the

GetXml method). The contents of the calling email object are erased and replaced with the email contained within the XML string.

Returns True for success, False for failure.
link

answered Sep 05 at 21:57

webified's gravatar image

webified
32

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×200
×51

Asked: Sep 04 at 22:29

Seen: 211 times

Last updated: Sep 06 at 22:45

powered by OSQA