Archived Forum Post

Index of archived forum posts

Question:

[WP8] Access Violation Error - SendEmail - Windows Phone Runtime Component

Jun 13 '14 at 11:42

First of all, warm greetings to all the members of this forum. I have just registered and this is my first post here. :)

Getting back to the business..

I am evaluating the Chilkat Windows Phone Runtime Component (http://www.chilkatsoft.com/winPhone.asp) for its IMAP and POP support for Windows Phone 8 XAML/C# app. But, am facing issues while trying to send an email through SMTP server using this Component on WP8. I have already searched through this forum, but did not find a discussion on the issue I am facing, hence this question.

Following is the code snippet that I have in OnNavigatedTo() of MainPage.xaml.cs in WP8 App:

        // Initialize mail manager..
        Chilkat.MailMan mailMan = new MailMan();
        mailMan.UnlockComponent("30-day trial");
        mailMan.SmtpHost = "smtp.xyz.com";
        mailMan.SmtpPassword = "decoderPassword";
        mailMan.SmtpUsername = "decoder@xyz.com";
        mailMan.SmtpPort = 587;

        mailMan.OpenSmtpConnection();

        // Form an email to send..
        Email mail = new Email();
        mail.FromAddress = "decoder@xyz.com";
        mail.From = "decoder@xyz.com";
        mail.FromName = "Decoder";
        mail.AddTo("Decoder-Gmail", "decoder@gmail.com");
        mail.Subject = "Test Mail";
        mail.Body = " This is a test mail.";

        if(!mailMan.IsUnlocked())
        {
            MessageBox.Show("MailMan not unlocked: " + mailMan.LastErrorText);
            return;
        }
        if (mailMan.IsSmtpConnected)
        {
            // Send email..
            bool bSendResult = mailMan.SendEmail(mail);
            if (bSendResult == true)
                MessageBox.Show("Mail sent successfully.");
            else
                MessageBox.Show("Mail send failed: " + mailMan.LastErrorText);
        }
        else
        {
            MessageBox.Show("Failed to connect to SMTP server: " + mailMan.LastErrorText);
        }

When mailMan.SendEmail(mail) is executed, it triggers an Access Violation Exception.

Exception Details:

System.AccessViolationException was unhandled HResult=-2147467261 Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. InnerException: null

Note: I am using the 30 day-evaluation and have set the Unlock Component to "30-day Trial" in mailMan.

Can you please help me resolve this issue? Has anyone encountered this issue or been able to successfully use this component for WP8?


Accepted Answer

This new build fixes it:

http://www.chilkatsoft.com/download/9.5.0.40/chilkat-9.5.0-winPhoneRTC.zip

The problem was caused by a bug in the outer-layer CX code generation. Given that the new version (v9.5.0.40) was only out for 1 or 2 days, and that it was a simple fix in the outer-layer generated code, which means it wasn't an internal problem and only affects the Windows Phone RTC build, Chilkat did not increment the version number. The problem was related to any method that passes an object reference in the method arguments.


Answer

Thanks for the report. I'm testing to see if I can reproduce the problem..