Testing version 4.6.5

Discussions related to custom development with Select.
kevinfoster
Posts: 2
Joined: Fri Feb 07, 2020 1:10 pm

Re: Testing version 4.6.5

Post by kevinfoster » Wed Feb 19, 2020 8:22 pm

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?

BobRichards
Posts: 906
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Testing version 4.6.5

Post by BobRichards » Thu Feb 20, 2020 11:25 am

I have not encountered this issue. I have sent a request for assistance to our 4.6 developers.
Bob Richards, Software Developer, SoftPro

enendza
Posts: 59
Joined: Wed Oct 16, 2019 12:22 pm

Re: Testing version 4.6.5

Post by enendza » Tue Feb 25, 2020 8:30 am

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
Attachments
SampleSPCodeError.png
SampleSPCodeError.png (24.5 KiB) Viewed 2680 times
SampleSPCode.png
SampleSPCode.png (45.7 KiB) Viewed 2680 times

enendza
Posts: 59
Joined: Wed Oct 16, 2019 12:22 pm

Re: Testing version 4.6.5

Post by enendza » Tue Feb 25, 2020 8:34 am

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
Attachments
SampleSPCodeErrorStackTrace.png
SampleSPCodeErrorStackTrace.png (122.69 KiB) Viewed 2679 times

enendza
Posts: 59
Joined: Wed Oct 16, 2019 12:22 pm

Re: Testing version 4.6.5

Post by enendza » Fri Feb 28, 2020 12:56 pm

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

BobRichards
Posts: 906
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Testing version 4.6.5

Post by BobRichards » Fri Feb 28, 2020 2:18 pm

Thanks for posting your fix!
Bob Richards, Software Developer, SoftPro

Post Reply