Page 4 of 4

Re: Testing version 4.6.5

Posted: Wed Feb 19, 2020 8:22 pm
by kevinfoster
Hey Bob.
An issue we have found using version 4.6.5 of SoftPro is that anytime we create an instance of the SelectServer object( such as SelectServer ss = new SelectServer(new Uri(SP_URI), creds)), it causes SmtpClient to throw an error of:

Unable to cast object of type 'System.Net.Mail.SmtpClient' to type 'System.Net.HttpWebRequest'.

when sending a MailMessage with SmtpClient, with a stack trace of

at SoftPro.ClientModel.Security.SiteManager.CertificateValidationCallBack(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
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.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, 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.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state).

Any idea on what could be causing this?

Re: Testing version 4.6.5

Posted: Thu Feb 20, 2020 11:25 am
by BobRichards
I have not encountered this issue. I have sent a request for assistance to our 4.6 developers.

Re: Testing version 4.6.5

Posted: Tue Feb 25, 2020 8:30 am
by enendza
Morning-

Just wanted to follow up on this issue. Here is the simplest code example to reproduce what we are seeing.

Console App
.NET Framework
Framework 4.7.2

1st print screen shows the code
2nd print screen the error

If we just remove this ONE like of code "SelectServer ss = new SelectServer(new Uri(SP_URI), creds);" the SelectServer declaration the email delivery works fine, however, with that line of code we can't get the standard SMTP client email delivery to work. We get this error "Unable to cast object of type SmtpClient to HttpWebRequest"

What are we missing? I tried to attached the sample project but the zip file was 11 MEG and it was too large to attach, please let us know if you would like this simple project file with the source code.

Thanks for the help.

Emma

Re: Testing version 4.6.5

Posted: Tue Feb 25, 2020 8:34 am
by enendza
Also I have attached the stacktrace of the error that shows the source as "SoftPro.ClientModel" -

The references in the project are:

SoftPro.Accounting.Client
SoftPro.ClientModel
SoftPro.Documents.Client
SoftPro.EntityModel
SoftPro.Imaging.Client
SoftPro.OrderTracking.Client
SoftPro.ProceedsTracking.Client
SoftPro.Register.Client
SoftPro.Reporting.Client
SoftPro.Select.Client

Re: Testing version 4.6.5

Posted: Fri Feb 28, 2020 12:56 pm
by enendza
Added these lines of code and the error went away

ServicePointManager.ServerCertificateValidationCallback = AcceptAllCertifications

private static bool AcceptAllCertifications(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}

Seems that there are two different Certificates in use when a SoftPro Server is connecting and an Office365 email connection is connecting and we just had to override any exceptions and AcceptAllCertifications and we were ok.

Hope this helps anyone else facing this challenge

Emma

Re: Testing version 4.6.5

Posted: Fri Feb 28, 2020 2:18 pm
by BobRichards
Thanks for posting your fix!