SMTPClient.Send crashes production application

2019-08-05 11:52发布

问题:

I have used the System.Net.Mail.SMTPClient class in virtually every application I have developed. I have never had any issues with it. However, I am encountering an extremely annoying situation in which a call to SMTPClient.Send causes my production application to crash EVEN WITHIN A TRY/CATCH BLOCK, and THE EXE IS DELETED!

WTF. In the development environment there is no problem whatsoever, email is sent without a hitch.

The application is written in C# and created in Visual Studio 2010. I have a setup project which creates the setup.exe file that the app is installed with. Every time that the production app calls STMPClient.Send it crashes without warning and the EXE disappears.

I have verified all smtp settings and, as I said, there is no problem when running in the development environment.

Does anyone have any idea what could be causing this strange behavior?

回答1:

This has been resolved already through a comment, but adding an answer for future references

Check your anti-virus settings, it might not like it and remove the executable without any warnings. If you are deploying this on client's computers, make sure you purchase a Software Publisher's Digital Certificate. But if your app has been "blacklisted" you might need to take further steps, like submitting a whitelist request to the pertinent entity.