Archived Forum Post

Index of archived forum posts


System.AccessViolationException when instantiating new Email() object

Oct 04 '13 at 11:44

I've gotten some feedback from users of my WindowSMART 2013 software that they noticed the WindowSMART service was stopped. WindowSMART 2013 is a hard disk and SSD health monitor, so people who use WindowSMART (or its companion Home Server SMART) expect it to be running.

Our software uses Gurock Software Smart Inspect for debug logging, so I am able to pinpoint the exact line of code causing the crash. Of course, I also have the Windows Application event log, which provides a stack trace.

The problem is a System.AccesViolationException which is raised when instantiating a new Email object. The more intriguing thing is that the service crashes with an unhandled exception despite the fact that the offending line of code is in a try block! (I would think my catch block would pick that up.)


            // Set up the Chilkat.MailMan object and license it.
            SiAuto.Main.LogMessage("Set up the Chilkat.MailMan object and license it.");
            MailMan mailman = new MailMan();
            bool success = mailman.UnlockComponent("My_License_Key_Goes_Here");

            if (!success)
                SiAuto.Main.LogError("Failed to activate MailMan object: " + mailman.LastErrorText);
                throw new UnauthorizedAccessException("Cannot activate Chilkat.MailMan email module. The licensing module encountered an exception.");

            // Point to the mail server.
            // Set the SMTP Server and SSL options.
            mailman.SmtpHost = mailServer;
            mailman.SmtpPort = serverPort;
            mailman.SmtpSsl = useSsl;

            // Creds
            if (authenticationEnabled)
                mailman.SmtpUsername = mailUser;
                mailman.SmtpPassword = mailPassword;

            // Create a new email object.
            SiAuto.Main.LogMessage("Compose email message.");
            Email msg = new Email(); // *** EXCEPTION OCCURS HERE ***

            // Bunch of other stuff goes here -- set priority, send message, etc.

            catch (Exception ex)
                SiAuto.Main.LogError("Failed to send email. Correlation ID=" + guid);

BELOW IS THE STACK TRACE FROM THE APPLICATION EVENT LOG Sorry if some items seem cryptic; WindowSMART/Home Server SMART is obfuscated with Eazfuscator.NET so some method or parameter names may look awkward.

Application: HomeServerSMART2013.Service.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException Stack: at <module>.ClsEmail.{ctor}(ClsEmail) at <module>.ClsEmail.{ctor}(ClsEmail) at Chilkat.Email..ctor() at DojoNorthSoftware.WindowsServerSolutions.HomeServerSMART2013.Components.HssServiceHelper.(System.String, System.String, System.Net.Mail.MailPriority, System.String) at DojoNorthSoftware.WindowsServerSolutions.HomeServerSMART2013.Components.HssServiceHelper.(System.String, System.String, Boolean, Boolean, Boolean) at DojoNorthSoftware.WindowsServerSolutions.HomeServerSMART2013.Components.HssServiceHelper.PostSpecialNotificate(System.String, System.String, Boolean, System.String, Int32) at DojoNorthSoftware.WindowsServerSolutions.HomeServerSMART2013.Components.HssServiceHelper.PostPowerNotificate(System.String, System.String, Boolean, System.String, Int32) at .OnPowerEvent(System.ServiceProcess.PowerBroadcastStatus) at System.ServiceProcess.ServiceBase.DeferredPowerEvent(Int32, IntPtr) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr, System.Object[], System.Object, System.Object[] ByRef) at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessageSink) 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.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch()

Faulting application name: HomeServerSMART2013.Service.exe, version:, time stamp: 0x524daf57 Faulting module name: ChilkatDotNet4.dll, version:, time stamp: 0x50d0f6e0 Exception code: 0xc0000005 Fault offset: 0x00000000002ac6d8 Faulting process id: 0x1ccc Faulting application start time: 0x01cec061c77b5c81 Faulting application path: C:Program FilesDojo North SoftwareWindowSMARTHomeServerSMART2013.Service.exe Faulting module path: C:Program FilesDojo North SoftwareWindowSMARTChilkatDotNet4.dll Report Id: 368b0d7a-2c55-11e3-966b-e02a82ca9ebd


I would recommend updating to the latest version of Chilkat (v9.4.1 SP1). It's impossible to say what it could be given the information, but it's very possible that the underlying cause was something already fixed.