【发布时间】:2013-06-04 18:00:25
【问题描述】:
几个月前我在 Azure 网站上部署了一个应用程序,它按预期工作。昨天,在微软发布了一组新功能后,我注意到有一个选项可以从 32 位更改为 64 位。我将网站配置从 32 位更改为 64 位。除了我尝试使用标准 SMTP .NET 库通过 SendGrid 发送电子邮件时,所有网站都可以正常工作。
这是我得到的例外:
访问被拒绝" source="System" detail="System.Net.NetworkInformation.NetworkInformationException (0x80004005):访问在 System.Net.NetworkInformation.SystemIPGlobalProperties.GetFixedInfo() 在系统被拒绝.Net.NetworkInformation.SystemIPGlobalProperties.get_FixedInfo() 在 System.Net.NetworkInformation.SystemIPGlobalProperties.get_HostName() 在 System.Net.Mail.SmtpClient.Initialize() 在 System.Net.Mail.SmtpClient..ctor()
这是代码:
var toAddress = new MailAddress(to, username);
using (var smtp = new SmtpClient())
using (var message = new MailMessage() {Subject = subject, IsBodyHtml = true})
{
message.To.Add(toAddress);
message.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(body, null, MediaTypeNames.Text.Html));
smtp.Send(message);
}
Web.config:
<system.net>
<mailSettings>
<smtp from="xxx@xxx.com">
<network host="smtp.sendgrid.net" port="587" userName="xxx@azure.com" password="xxxxx" />
</smtp>
</mailSettings>
</system.net>
我的开发环境配置为 64 位,应用程序可以发送电子邮件。 知道为什么它在 Azure 64 位模式下会失败吗?
谢谢!
【问题讨论】:
-
您是在
Full Trust还是Windows Azure Partial Trust中部署您的云服务? -
我正在使用网站进行部署。默认情况下是完全信任的。
-
我遇到了同样的问题。将其切换回 32 位修复它。有人对差异有解释吗?
-
我遇到了同样的问题,将它改回 32 位修复了它。最奇怪的事情。很想知道为什么。